Skip to content

Instantly share code, notes, and snippets.

Avatar

Louis Dionne ldionne

View GitHub Profile
View zip_with.cpp
/*!
* Barebones zip_with and fmap for std::tuple and std::integer_sequence.
*
* Copyright Louis Dionne 2014
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE.md or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
// Compiled with:
@ldionne
ldionne / benchmark.hpp
Last active Aug 29, 2015
Support header for runtime benchmarks with the Benchcc gem.
View benchmark.hpp
/*
@copyright Louis Dionne 2014
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_HANA_BENCHMARK_MEASURE_HPP
#define BOOST_HANA_BENCHMARK_MEASURE_HPP
#include <chrono>
@ldionne
ldionne / when.md
Created Oct 7, 2014
NXXXX: Flexible partial specialization with `when` and `when_valid`
View when.md

Flexible partial specialization with when and when_valid

  • Document Number: NXXXX
  • Date: 2014-10-07
  • Programming Language C++, Library Evolution Working Group
  • Reply-to: Louis Dionne ldionne.2@gmail.com

Introduction

@ldionne
ldionne / no_adl.cpp
Created Mar 5, 2015
Make sure Hana avoids undesirable instantiations because of ADL.
View no_adl.cpp
template <typename ...T>
struct _tuple_t {
struct _;
};
template <typename ...T>
struct _tuple_t<T...>::_
: _tuple_t<T...>
{ };
@ldionne
ldionne / compile_time_printf.cpp
Created Mar 12, 2015
Create a printf-style format string at compile-time
View compile_time_printf.cpp
#include <type_traits>
#include <boost/hana.hpp>
#include <boost/hana/ext/std/type_traits.hpp>
#include <iostream>
using namespace hana;
constexpr auto formats = hana::make_map(
hana::make<hana::Pair>(hana::type<int>, hana::string<'%', 'd'>),
hana::make<hana::Pair>(hana::type<float>, hana::string<'%', 'f'>),
View GCC ICE output.txt
› ~/code/gcc5/bin/g++ -std=c++1y ~/code/hana/test/worksheet.cpp
/Users/ldionne/code/hana/test/worksheet.cpp: In substitution of ‘template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = std::is_same<T, T>{}(); _Tp = void]’:
/Users/ldionne/code/hana/test/worksheet.cpp:1411:25: required from here
/Users/ldionne/code/hana/test/worksheet.cpp:1408:50: in constexpr expansion of ‘((std::integral_constant<bool, true>*)(& std::is_same<T, T>()))->std::integral_constant<_Tp, __v>::operator()<bool, true>()’
/Users/ldionne/code/hana/test/worksheet.cpp:1411:25: internal compiler error: in cxx_eval_call_expression, at cp/constexpr.c:1358
auto ICE_HERE = __func__;
^
/Users/ldionne/code/hana/test/worksheet.cpp:1411:25: internal compiler error: Abort trap: 6
g++: internal compiler error: Abort trap: 6 (program cc1plus)
@ldionne
ldionne / GSoC2015.md
Last active Aug 29, 2015
Proposition for GSoC 2015 with Boost
View GSoC2015.md

Abstract

The goal of this project is to improve the compile-time associative data structures present in the Hana C++14 metaprogramming library. I aim to provide a richer interface than what is currently available and also to improve the compile-time performance of those data structures, while keeping the runtime performance on-par with non-naive hand-written code.

Background information

@ldionne
ldionne / jump_table.cpp
Created May 13, 2015
implementation of a function pointer table
View jump_table.cpp
// Copyright Louis Dionne 2015
// Distributed under the Boost Software License, Version 1.0.
#include <boost/hana.hpp>
#include <array>
using namespace boost::hana;
template <typename T>
void visit(T t) { }
@ldionne
ldionne / src_exception.patch
Created Jun 2, 2015
Patch for src/exception.cpp in libc++
View src_exception.patch
diff --git a/src/exception.cpp b/src/exception.cpp
index a13a0b9..2c16060 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -105,9 +105,9 @@ terminate() _NOEXCEPT
#endif // !__EMSCRIPTEN__
#endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
+#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
@ldionne
ldionne / bloat.erb.json
Last active Aug 29, 2015
Various implementations of degenerate use case presented at http://thread.gmane.org/gmane.comp.lib.boost.devel/260913/focus=261035
View bloat.erb.json
<%
hana_tuple = (1..200).step(10)
hana_map = (1..50).step(10).to_a
mpl = hana_tuple
%>
{
"title": {
"text": "Executable size"