Skip to content

Instantly share code, notes, and snippets.

View ricejasonf's full-sized avatar

Jason Rice ricejasonf

  • Henderson, NV
View GitHub Profile
@ricejasonf
ricejasonf / CMakeLists.txt
Created March 19, 2016 02:01
Refactor Some CamelCase
set(LLVM_LINK_COMPONENTS support)
add_clang_executable(my_refactor
my_refactor.cpp
)
target_link_libraries(my_refactor
clangTooling
clangBasic
clangASTMatchers
)
@ricejasonf
ricejasonf / filter_integrals.cpp
Last active March 2, 2016 17:32
Filter Index Sequence
#include<boost/hana/filter.hpp>
#include<utility>
#include "hpesoj_utility.hpp"
namespace hana = boost::hana;
struct is_even_t {
template <int i>
struct apply {
@ricejasonf
ricejasonf / types_sequence.cpp
Last active February 25, 2016 03:04
Hana Experimental Types Sequence
#include<boost/hana.hpp>
#include<boost/hana/experimental/types.hpp>
namespace hana = boost::hana;
namespace hanax = boost::hana::experimental;
int main() {
{
constexpr auto xs = hanax::types<
hana::int_<1>,
@ricejasonf
ricejasonf / PartialRef.hpp
Created January 14, 2016 04:40
Lame wrapper for `hana::partial` to use `std::ref`s
//
// Copyright Jason Rice 2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef NBDL_DETAILS_PARTIAL_REF_HPP
#define NBDL_DETAILS_PARTIAL_REF_HPP
#include<boost/hana.hpp>
@ricejasonf
ricejasonf / member_template.cpp
Created December 8, 2015 19:40
Class Template Member Class Template Definition
#include<boost/hana.hpp>
#include<iostream>
namespace hana = boost::hana;
template<typename T>
class A
{
static constexpr const char* t = hana::to<const char*>(T{});
@ricejasonf
ricejasonf / general_make.cpp
Last active December 8, 2015 00:51
C++14 Universal `make` function
#include<type_traits>
#include<iostream>
template<typename T1, typename T2>
class Moo
{
T1 t1;
T2 t2;
public:
@ricejasonf
ricejasonf / Makefile
Last active December 3, 2015 20:39
Precompiled Header Experiment
CC=clang++ -std=c++14
all: main
main: main.cpp all.hpp.pch
$(CC) main.cpp -include-pch all.hpp.pch -o main
all.hpp.pch: expensive.hpp
$(CC) expensive.hpp -o all.hpp.pch
@ricejasonf
ricejasonf / pseudocode
Last active December 2, 2015 16:19
Primality Test
function is_prime(n : integer)
if n ≤ 1
return false
else if n ≤ 3
return true
else if n mod 2 = 0 or n mod 3 = 0
return false
let i ← 5
while i×i ≤ n
if n mod i = 0 or n mod (i + 2) = 0
@ricejasonf
ricejasonf / CMakeLists.txt
Last active November 30, 2015 19:32
Bloat Tests for Large Map
cmake_minimum_required(VERSION 2.8)
add_definitions(-std=c++14)
add_definitions(-Wall)
add_definitions(-Wextra)
include_directories("/usr/local/include")
add_executable(large_map_1
large_map_1.cpp
@ricejasonf
ricejasonf / test1.cpp
Last active November 26, 2015 02:27
Benchmark checking for duplicate types.
#include<boost/hana.hpp>
namespace hana = boost::hana;
auto list_with_no_dups =
hana::unpack(
hana::range_c<int, 0, 50>,
[](auto... i) {
return hana::tuple_c<int, i...>;
});