Generating Spirit parser expressions from a variadic list of alternative parser expressions

Thank you for a quick hint! I’ve just tried your code and unless I do something wrong … I get this output: Syntax error:abc 8.81 Parsed:-a atoken Syntax error:-b btoken Syntax error:-c ctoken Syntax error:-d dtoken – G. Civardi 2 hours ago Okay, so, I couldn’t leave it alone :/ Turns out there was Undefined … Read more

C++11 “overloaded lambda” with variadic template and variable capture

Overload resolution works only for functions that exist in a common scope. This means that the second implementation fails to find the second overload because you don’t import function call operators from overload<Frest…> into overload<F0, Frest…>. However, a non-capturing lambda type defines a conversion operator to a function pointer with the same signature as the … Read more

Variadic templates

One of the simplest possible examples is the following implementation of max which isn’t even templated on types. int maximum(int n) { return n; } template<typename… Args> int maximum(int n, Args… args) { return max(n, maximum(args…)); } Only slightly more complex is the canonical printf implementation: void printf(const char *s) { while (*s) { if … Read more

Is there a name for this tuple-creation idiom?

I think this is a subtle implementation of a Monad-like thing, specifically something in the same spirit of the continuation monad. Monads are a functional programming construction used to simulate state between different steps of a computation (Remember that a functional language is stateless). What a monad does is to chain different functions, creating a … Read more

Variadic deduction guide not taken by g++, taken by clang++ – who is correct?

This is gcc bug 80871. The issue is, we end up with this set of candidates for deduction: template <class… Types, class… Args> list<Types…> __f(Args… ); // constructor template <class… Args> list<Args…> __f(Args… ); // deduction-guide Both are valid (Types… can deduce as empty in the first case), but the call here should be ambiguous … Read more