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 / large_map.cpp
Last active November 12, 2015 00:45
Hana map thing that doesn't compile on my linux box.
#include<boost/hana.hpp>
#include<vector>
#include<iostream>
namespace hana = boost::hana;
struct Tag1 {};
struct Tag2 {};
struct Tag3 {};
@ricejasonf
ricejasonf / reverse_hana.cpp
Last active November 3, 2015 20:16
Hand Written C++11 Sequence Reverse Migrated to Hana
#include<boost/hana.hpp>
namespace hana = boost::hana;
constexpr auto my_sequence = hana::tuple_t<int, float, char>;
constexpr auto my_sequence_reversed = hana::tuple_t<char, float, int>;
static_assert(hana::reverse(my_sequence) == my_sequence_reversed, "");
int main()
@ricejasonf
ricejasonf / test_variant.cpp
Created August 8, 2015 23:47
A variant type I made. :D
#include<string>
#include<nbdl>
#include "catch.hpp"
TEST_CASE("Unitialized variant should match Unresolved.", "[variant]")
{
using Number = nbdl::Variant<int, std::string, float>;
Number number;
REQUIRE(number.match(
[](nbdl::Unresolved) {
@ricejasonf
ricejasonf / variant_callback.cpp
Last active August 29, 2015 14:26
Nifty type matching for a lightweight variant type I am working on.
#include<nbdl>
#include "catch.hpp"
struct Type1 {};
struct Type2 {};
struct Type3 {};
struct Type4 {};
template<typename T>
int getInt(T tag)
{
#include<iostream>
template<typename T>
struct LambdaTraits
{
using ReturnType = typename LambdaTraits<decltype(&T::operator())>::ReturnType;
};
template<typename ClassType, typename Return, typename... Args>
struct LambdaTraits<Return(ClassType::*)(Args...) const>
{