Skip to content

Instantly share code, notes, and snippets.

View willkill07's full-sized avatar
🏠
Working from home

Will Killian willkill07

🏠
Working from home
View GitHub Profile
@willkill07
willkill07 / json.cpp
Last active June 26, 2022 14:09
JSON parser in modern C++
#include "json.hpp"
namespace json {
Wrapper::Wrapper(Value const &value) : v{value} {}
Wrapper::Wrapper(Value &value) : v{value} {}
Wrapper::operator Value &() { return v; }
Wrapper::operator Value const &() const { return v; }
#include <stdio.h>
#include <stdarg.h>
static void d̰̞ͅi̜̣̣̤̪s͎̬̙p̫̞͕̹̣͉̙a̘̞̼͕̲ͅt̰̳c͚̟̳͎̻̘ͅh̻͠(const char* f̢̬͉̥̮͈̦̤m̨t̴̝̳, ...)
{
va_list a̢͍͉̪͝p̨̙͎͙̳;
va_start(a̢͍͉̪͝p̨̙͎͙̳, f̢̬͉̥̮͈̦̤m̨t̴̝̳);
vfprintf(stderr, f̢̬͉̥̮͈̦̤m̨t̴̝̳, a̢͍͉̪͝p̨̙͎͙̳);
va_end(a̢͍͉̪͝p̨̙͎͙̳);
@willkill07
willkill07 / AddClangPlugin.cmake
Last active June 30, 2017 18:06
Clang Plugin CMakeLists.txt
find_package(Clang REQUIRED)
set(CLANG_LIBRARIES clangAST clangASTMatchers clangAnalysis clangBasic clangDriver clangEdit clangFrontend clangFrontendTool clangLex clangParse clangSema clangEdit clangRewrite clangRewriteFrontend clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore clangSerialization clangToolingCore clangTooling clangFormat)
macro(add_clang_plugin _name)
add_library(${_name} SHARED "")
set_target_properties(${_name}
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED On
@willkill07
willkill07 / PolicyBase.hpp
Last active July 20, 2017 03:53
OpenMP policy tag dispatching
#ifndef POLICY_BASE_HPP_
#define POLICY_BASE_HPP_
#include <cstdio>
#include "meta.hpp"
// Policy base
enum class Policy { seq, openmp, target_openmp };
@willkill07
willkill07 / 10.13_compat_homebrew.sh
Created September 16, 2017 17:06
high sierra compatibility
echo "type in a brew package name and press enter"
echo "to end your queries, send EOF (Ctrl+D)"
echo "> "
while read -r package
do
brew info $package | \
awk '/^From:/{
gsub(/github.com/,"raw.githubusercontent.com")
gsub(/\/blob\//,"/")
print $2
@willkill07
willkill07 / fib_lol.cpp
Created September 26, 2017 22:07
Fib Fun
#include <array>
#include <utility>
using Int = unsigned long long;
template<Int N, Int A = 0x0llu, Int B = 0x1llu>
constexpr Int Fib = []() constexpr {
if constexpr(N == 0)
return A;
else if constexpr(N == 1)
@willkill07
willkill07 / lisp.cpp
Created September 13, 2019 21:46
Lisp Evaluator C++ TMP
template <typename T> auto declval() -> T&&;
template <class... Args> using eval = decltype(evaluate(declval<Args>()...));
template <class... Args> using eval2 = decltype(evaluate2(declval<Args>()...));
template <class... Args> using eval3 = decltype(evaluate3(declval<Args>()...));
template <class...>
struct L{};
// the datatype cons (not the keyword)
template <class, class>
// Prevent warning when testing the Abstract test type.
#include <type_traits>
template <typename...>
struct voider {
using type = void;
};
template<typename ... Ts>
using void_t = typename voider<Ts...>::type;
template<typename T, typename U = std::remove_all_extents_t<T>>
using has_dtor = decltype(std::declval<U&>().~U());
class Empty
{};
class NotEmpty
{
virtual ~NotEmpty();
};
#include <type_traits>
template <template <class... Ts> class Name, class ... Args>
struct Concept {
};
template <class> struct CheckConcept;
//#define RAJA_CXX_VERSION 17