Skip to content

Instantly share code, notes, and snippets.

@jamboree
jamboree / grammar.hpp
Last active August 29, 2015 14:00
replacement of boost/spirit/home/x3/nonterminal/grammar.hpp
/*=============================================================================
Copyright (c) 2001-2013 Joel de Guzman
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)
==============================================================================*/
#if !defined(BOOST_SPIRIT_X3_GRAMMAR_JAN_19_2012_0454PM)
#define BOOST_SPIRIT_X3_GRAMMAR_JAN_19_2012_0454PM
#if defined(_MSC_VER)
@jamboree
jamboree / monster.cpp
Last active August 29, 2015 14:00
some modifications using my experimental features
#include <string>
#define BOOST_SPIRIT_X3_NO_RTTI
#include <boost/spirit/home/x3.hpp>
#include <boost/spirit/home/x3/support/ast/variant.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
namespace x3 = boost::spirit::x3;
#include <iostream>
template<char...>
struct str {};
template<char c>
struct ch {};
template<int n>
using idx = std::integral_constant<int, n>;
@jamboree
jamboree / lit
Last active August 29, 2015 14:05
#include <iostream>
#include <utility>
#include <tuple>
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/cat.hpp>
template<char... cs>
using str = std::integer_sequence<char, cs...>;
#include <iostream>
template<class A, class B>
struct P;
template<class... Ts>
struct L {};
template<class T, class... Ts>
using mul = L<P<T, Ts>...>;
#include <iostream>
#include <cstdio>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
int main(int argc, char** argv)
{
namespace ipc = boost::interprocess;
std::fclose(std::fopen("lock", "w"));
ipc::file_lock flock("lock");
#include <iostream>
#include <exception>
#include <functional>
#include <memory>
#include <boost/context/all.hpp>
#include <boost/optional/optional.hpp>
struct forced_unwind {};
struct resumer_base
#include <iostream>
__attribute__((noinline)) bool is_upward_test(char* a)
{
char b[32];
return a < b;
}
bool is_upward()
{
#include <iostream>
#include <boost/context/all.hpp>
bool is_upward()
{
struct C
{
boost::context::fcontext_t master;
char stack1[512], stack2[512];
} c;
#include <iostream>
// Kahan summation algorithm
template<class T>
struct accum
{
T t, y;
accum(T val = 0): t(val), y() {}