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 / 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 / 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
#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 / 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; }
@willkill07
willkill07 / StrongTyping.hpp
Last active May 17, 2017 02:45
Strong Typing in C++14
#include <type_traits>
#include <utility>
namespace detail {
template <typename Seq, std::size_t Idx, typename T, T Val, T DefaultVal>
struct make_list_with_index_value;
template <std::size_t Idx, typename T, T Val, T DefaultVal, std::size_t ... Ids>
struct make_list_with_index_value<std::index_sequence<Ids...>, Idx, T, Val, DefaultVal> {
using type = std::integer_sequence<T, ((Idx == Ids) ? Val : DefaultVal)...>;
};
@willkill07
willkill07 / concat.hpp
Last active May 15, 2017 20:12
tinymeta
namespace impl {
template <template <class ...> class L, class = L<>, class = L<>, class ...>
struct concat_ {
using type = L<>;
};
template <template <class ...> class L,
template <class ...> class L1, class ... T1>
struct concat_<L, L1<T1...>> {
using type = L<T1...>;
@willkill07
willkill07 / StrongType.hpp
Last active May 9, 2017 19:43
Strong Typing in C++11
#include <type_traits>
template <typename T, typename Tag>
struct StrongType {
T value;
explicit StrongType(T v) : value(v) {}
StrongType() = default;
StrongType(StrongType const &) = default;
StrongType(StrongType &&) = default;
@willkill07
willkill07 / ReduceRedux.cpp
Last active May 4, 2017 03:50
RAJA Reduce Redux
// use C++11 to compile
#include <array>
#include <limits>
#include <numeric>
#include <type_traits>
#ifdef _OPENMP
#include <omp.h>
#endif
// Expressive Pi
// -------------
//
// Fluent C++ Blog Post: The Pi Day Challenge for Expressive Code
// http://www.fluentcpp.com/2017/03/02/the-pi-day-challenge-for-expressive-code-in-c/
//
// Author: William Killian
// Email: [email protected]
// Github: http://www.github.com/willkill07
// Website: https://www.eecis.udel.edu/~wkillian
@willkill07
willkill07 / .clang-format
Last active September 21, 2017 12:29
Zoppetti-like .clang-format
BasedOnStyle: Mozilla
AlignAfterOpenBracket: Align
AlignEscapedNewlinesLeft: 'true'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'