Skip to content

Instantly share code, notes, and snippets.

View cppljevans's full-sized avatar

Larry Evans cppljevans

  • 19:25 (UTC -12:00)
View GitHub Profile
@cppljevans
cppljevans / lambda_tagged_tuples.cpp
Last active August 29, 2015 14:02
Prototype of lisp like lambda's based on Dionne's post "Efficient tuple implementation"
//Purpose:
// Test if the code posted here:
/*
http://article.gmane.org/gmane.comp.lib.boost.devel/251897
*/
// With headers:
/*
From: Louis Dionne <[email protected]>
Newsgroups: gmane.comp.lib.boost.devel
Subject: Efficient tuple implementation
@cppljevans
cppljevans / variable_templates.limits.max.cpp
Created November 21, 2014 21:56
demo n3651 with macro's illustrating when "duplicate declaration" is needed (at least with clang3.5)
//Purpose:
// Test compiler implementation of
// "variable templates" as described in:
/*
http://isocpp.org/files/papers/N3651.pdf
*/
// and as commented on here:
/*
http://en.cppreference.com/w/Talk:cpp/language/variable_template
*/
@cppljevans
cppljevans / toy_why_define.cpp
Last active August 24, 2016 08:55
spirit toy.cpp modified to show need for BOOST_SPIRIT_DEFINE
//Purpose:
// Demonstrate the purpose BOOST_SPIRIT_DEFINE
// is to implement recursive rules.
//OriginalSource:
// https://github.com/boostorg/spirit/blob/develop/workbench/x3/toy/toy.cpp
//Modifications:
// Rm'ed use of context to implement recursiion and replaced with
// BOOST_SPIRIT_DEFINE
//===========================================================================
#include <iostream>
@cppljevans
cppljevans / d0424r0_test.cpp
Created August 16, 2016 12:24
illuminate create_window code in D0424R0.pdf
//Purpose:
// Illustrate the workings of the create_window code found in attachment to:
/*
https://groups.google.com/a/isocpp.org/forum/?utm_medium=email&utm_source=footer#!msg/std-proposals/b1X597zMx9s/4fnQB6gBCwAJ
*/
//Modifications:
// Renamed create_window to named_args and renamed many other
// types and variables to make them more generic or readable.
// Added several comments explaining purpose of various parts.
// Added extensive print statements to illustrate how code
//Purpose:
// Experiment with different methods for making code here:
// https://github.com/Kojoley/spirit/blob/8b76132c8ded0c63b8ecc7d1689627ae49d1fde9/include/boost/spirit/home/x3/operator/detail/sequence.hpp#L419
// a little more modular and help to answer question about
// whether to use lamba's as posed by Joel here:
// https://github.com/boostorg/spirit/pull/370#issuecomment-369410876
//Result:
// Works both when
// defined(USE_CONSTEXPR_IF_LAMBDA)
// and when
@cppljevans
cppljevans / Show -I flag OK
Last active March 23, 2018 16:43
variant implicit conversion test
-*- mode: compilation; default-directory: "~/prog_dev/boost/releases/ro/boost_1_65_1/sandbox/kojoley/test/" -*-
Compilation started at Fri Mar 23 11:20:46
make -k ls
ls -ld ../x3-variant-fixes/include/*
drwxrwxr-x 3 evansl evansl 4096 Mar 22 19:40 ../x3-variant-fixes/include/boost
Compilation finished at Fri Mar 23 11:20:46
@cppljevans
cppljevans / x3-employee-annot_attr.cpp
Last active June 6, 2018 14:35
x3 employees using alternative to position_tagged
/*=============================================================================
Copyright (c) 2002-2015 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)
=============================================================================*/
///////////////////////////////////////////////////////////////////////////////
//
// A parser for arbitrary tuples. This example presents a parser
// for an employee structure.
@cppljevans
cppljevans / x3-only_1_xform-double_int.cpp
Created March 6, 2019 05:53
Joel's suggested changes (and a little more)
//Purpose:
// Follow Joel's suggestion about changing the
// xform_rule attribute to double expressed here:
// https://github.com/boostorg/spirit/issues/459#issuecomment-469476231
//Result:
// **SAME** result when defined(CALL_RULE_DEFINITION_SPECIALIZATION).
// IOW, the wrong value for `attr_rule`. Without this define,
// the results are as expected, i.e. `attr_rule` == 1235.
// However, that's because, **behind the scenes**, spirit is
// making a redundant (i.e. useless) call to the default
@cppljevans
cppljevans / date_parser-force_attr_propagation.cpp
Last active February 16, 2020 10:06
date_parser solution to stackoverflow problem
//Following code modifies:
// https://gist.github.com/cppljevans/0fede2c9c2e57f25712528dab4e6aec7#file-date_parser-rm_as_define-cpp
//by:
// 1) adding a macro, USE_ALTERNATIVES
// 2) using BOOST_FUSION_ADAPT_STRUCT
// 3) using rule
// 4) using force propagation flag in rule.
//to:
// show that even with attribute propagation, the attributes will not
// propage when there's any ALTERNATIVE's.
@cppljevans
cppljevans / sehe-coliru-stackoverflow-answer.cpp
Created March 6, 2020 12:19
skipper in recursive context leads to infinite template instantiation
//OriginalCode:
// http://coliru.stacked-crooked.com/a/d149f05af81bf0cf
//WhichWasAnswerTo:
// https://stackoverflow.com/questions/45899090/recursive-rule-in-spirit-x3/45900983
//DownloadedOn:
// 2020-03-06.0512CST
//Modifications:
// WHAT:
// * added macro, USE_TOP_LEVEL_SKIPPER
// * depending on defined(USE_TOP_LEVEL_SKIPPER)