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 / 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 / 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 / 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 / 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 / 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 / specialize_constexpr.cpp
Created March 19, 2016 22:12
Do Stuff Inside a Function That is Declared Constexpr
#include<iostream>
struct tag1 { };
struct tag2 { };
struct tag3 { };
struct tag4 { };
template <typename Tag>
struct foo_impl { };
#include<boost/hana.hpp>
namespace hana = boost::hana;
struct a_tag { };
struct b_tag { };
template <typename T>
constexpr auto get(T)
{
template <int v>
struct int_c { static constexpr int value = v; };
struct a_tag { };
struct b_tag { };
template <bool cond>
struct c_tag
{
static_assert(cond);
};
@ricejasonf
ricejasonf / aligned_union.cpp
Last active July 21, 2016 22:55
Invalid free when aligned_union is std::swap'd containing small std::string.
#include <string>
#include <type_traits>
#include <utility>
struct my_empty { };
using storage = std::aligned_union_t<sizeof(my_empty), my_empty, std::string>;
int main()
{
@ricejasonf
ricejasonf / package.json
Created September 13, 2016 22:41
Generate Markdown for Weekly Plan from PivotalTracker
{
"name": "pivotal-tools",
"version": "1.0.0",
"description": "",
"main": "weekly_plan.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jason Rice",
"license": "ISC",