Questions tagged [boost-mpl]

The Boost.MPL library is a general-purpose, high-level C++ template metaprogramming framework of compile-time algorithms, sequences and metafunctions. It provides a conceptual foundation and an extensive set of powerful and coherent tools that make doing explicit metaprogramming in C++ as easy and enjoyable as possible within the current language.

The Boost.MPL library is a general-purpose, high-level C++ template metaprogramming framework of compile-time algorithms, sequences and metafunctions. It provides a conceptual foundation and an extensive set of powerful and coherent tools that make doing explicit metaprogramming in C++ as easy and enjoyable as possible within the current language.

289 questions
2
votes
4 answers

C++ createObject() Factory

I would like to create a simple factory method with a simple C++ syntax: void *createObject(const char *str,...) { if(!strcmp("X",str)) return new X(...); } I cannot figure out the syntax for this. I've been looking at template…
user805547
  • 1,245
  • 1
  • 15
  • 23
2
votes
3 answers

Trouble with metafunction for identifying class-within-template-class

I have code with the following structure: template struct Foo { struct Bar { int data; }; }; I want to write metafunctions which will tell me if a type is either Foo or Bar. The first one is easy: template
GRedner
  • 31
  • 3
2
votes
1 answer

Call a protected base class function from nested struct

Normally nested structures have access to the owning classes public, protected and public member functions. There is also no problems calling a protected member function of a base class from within the nested structure, i.e. the following code…
mark
  • 7,381
  • 5
  • 36
  • 61
2
votes
1 answer

Using mpl::transform to generate a new sequence

I am trying to generate some generic configuration handling code that maps indexes to types, using a fusion::map with an internal format as follows: fusion::pair< mpl::int_< VALUE >, type >; To simplify generation of the map I have the following…
mark
  • 7,381
  • 5
  • 36
  • 61
2
votes
2 answers

Boost.MPL complexity

The boost::mpl::push_back documentation states that: push_back performs an insertion at the end of the sequence with guaranteed O(1) complexity. Is it complexity of compilation time?
mirt
  • 1,453
  • 1
  • 17
  • 35
2
votes
1 answer

How to use Boost Spirit with variant with more than 20 types?

I'm parsing a quite complex grammar with Boost Spirit and I'm facing a problem with a variant that have more than 20 types (21 here): namespace eddic { namespace ast { typedef boost::mpl::vector< Integer, IntegerSuffix, …
Baptiste Wicht
  • 7,472
  • 7
  • 45
  • 110
2
votes
1 answer

Boost.MPL transform with state?

I have the following mpl sequence boost::mpl::vector_c and i need to transform it according to the following algorithm (runtime version): i=0 output_sequence=[] for k in (0,...,len(input_sequence)-1): if…
Giuliano
  • 640
  • 3
  • 15
2
votes
1 answer

Metafunction for type conversion

Possible Duplicate: Where and why do I have to put the “template” and “typename” keywords? I am learning template programming by the book "C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond" and somehow I got…
nikolas
  • 8,707
  • 9
  • 50
  • 70
2
votes
2 answers

How can I return a variable number of containers of various types?

I have data that looks like this: token eps rank # first line names columns Intercept 9.362637e+00 1 # later lines hold data A1 -2.395553e-01 30 G1 -3.864725e-01 50 T1 1.565497e-01 …
flies
  • 2,017
  • 2
  • 24
  • 37
2
votes
1 answer

Compile time initialization of array using boost pp & mpl

Given: typedef boost::mpl::vector types; const size_t numTypes = boost::mpl::size::value; std::array, numTypes*numTypes> arr; I'm trying to get this sort of functionality in…
David
  • 27,652
  • 18
  • 89
  • 138
2
votes
1 answer

boost mpl integral type accumulate

How do I add the numbers? typedef boost::mpl::vector< boost::mpl::int_<1>, boost::mpl::int_<2>, boost::mpl::int_<3>, boost::mpl::int_<4>, boost::mpl::int_<5>, boost::mpl::int_<6> > ints; typedef boost::mpl::accumulate
Blair Davidson
  • 901
  • 12
  • 35
1
vote
1 answer

Using boost::mpl::vector to create variadic templates?

I'm stuck with C++03 for now, and I want to create a global function that accepts any number of type-safe arguments (up to a reasonable limit if necessary, like 9). I have access to the full boost library in my code base, so I'm hoping…
void.pointer
  • 24,859
  • 31
  • 132
  • 243
1
vote
2 answers

How should binary predicates be passed to a user-defined Boost.MPL algorithm?

Consider the following attempt at a Boost.MPL style metaprogramming version of std::any_of #include // cout #include // is_base_of, is_pod #include
TemplateRex
  • 69,038
  • 19
  • 164
  • 304
1
vote
2 answers

Changing the template arguments of derived classes

In the code below, C's base class B1's template argument OFFSET depends on B0, and B2 on B1. This is done by manual write the code every time an instance of C is created (in the main method). Is there a way to move this functionality to the…
Allan
  • 4,562
  • 8
  • 38
  • 59
1
vote
3 answers

Using boost::mpl, how can I get how many template classes are not "Empty", and call some macro with this number?

I want to call a macro with some arguments depending on the result of boost::mpl::eval_if (or a similar function) that could give how many template arguments are not empty. Say we have some pseudocode like the following: struct EmptyType { …
myWallJSON
  • 9,110
  • 22
  • 78
  • 149