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
1
vote
1 answer

Tag dispatching with transformed `boost::mpl::vector`s

I am trying to tag-dispatch into a function with a reversed copy of a boost::mpl::vector: using InitOrder = boost::mpl::vector< struct Foo, struct Bar, struct Baz >; template void…
Quentin
  • 62,093
  • 7
  • 131
  • 191
1
vote
1 answer

Can I use metaprogramming to transform a list of types into a new type that has specific implicit-conversion behavior to each type in the list?

I have a boost::mpl::vector containing several types, e.g. typedef boost::mpl::vector list_type; For some known types T1, T2, T3, T4. Is there any way to use metaprogramming to transform this list into a type that represents direct…
Jason R
  • 11,159
  • 6
  • 50
  • 81
1
vote
1 answer

How to get member type of boost::mpl placeholders during fold

Say there are two classes: struct A { using Key = int; using Value = char; }; struct B { using Key = char; using Value = float; }; I want to use their member types to define the Fusion map: typedef boost::fusion::map < …
Tarc
  • 3,214
  • 3
  • 29
  • 41
1
vote
1 answer

Calling a generic lambda in boost::mpl::for_each()

A few answers here (How to loop through a boost::mpl::list? being the one I started with) imply that I should be able to construct a generic lambda to feed to a boost::mpl::for_each() but I'm unable to find a working example, or build one…
Andy
  • 127
  • 1
  • 1
  • 8
1
vote
2 answers

Assert if template parameter is allowed

I'm trying to limit a templated method to a given list of allowed types and their "repeated" flavour. typedef boost::mpl::set allowedTypes; class Foo { typedef boost::mpl::set allowedTypes; …
codeJack
  • 2,423
  • 5
  • 24
  • 31
1
vote
0 answers

Boost MPL sequences and default parameters

I'm currently stuck on C++03, so variadic templates don't work for me. I can do what I want with a limited number of arguments using boost::mpl::vector and boost::mpl::inherit_linearly, but I want to do something similar to the following so the user…
Joe Sunday
  • 178
  • 1
  • 6
1
vote
1 answer

Derive from `boost::static-visitor` to remove code duplication

In one of my projects I'm using boost-variant excessively. At some point I exceeded the maximum number of template parameters (20) for boost-variant. Hence, I derived the following solution by linking several boost-variant Types together like a…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
1
vote
0 answers

Boost MPL push_back all elements in one vector into another

Just starting to look at boost MPL, say I have 2 vectors that I want to combine, is it possible with the boost MPL or do I need to write the code myself? Say I have: typedef vector vec1; typedef vector
CJCombrink
  • 3,738
  • 1
  • 22
  • 38
1
vote
1 answer

Boost mpl::vector and hana

I'm searching some kind of meta vector/linked list. Seems like mpl::vector was the best way of doing this. But now there is hana. Unfortunately I can't find some kind of hana::vector. I saw an adapter for mpl::vector that's all. So that's mean…
Mathieu Van Nevel
  • 1,428
  • 1
  • 10
  • 26
1
vote
1 answer

boost accumulator_set: expect primary expression

I am a new to Boost library. I want a program that could compute the min, max, mean and variance of a distance vector (of type std::vector < double >) and I wrote the following code std::vector < double > dist_err; // ... do something with…
Bojian Zheng
  • 2,167
  • 3
  • 13
  • 17
1
vote
2 answers

concatenate boost::mpl::string

How I can concatenate boost::mpl::string? The following code produce errors: #include #include #include #include #include #include…
niXman
  • 1,698
  • 3
  • 16
  • 40
1
vote
1 answer

boost::mpl::equal is always false for vector and vector_c

I'm trying to reproduce the example "3.1 Dimensional Analysis" from the book "C++ Template Metaprogramming" by Abrahams and Gurtovoy. At some moment, they compare that the "dimensions" of a value (of type mpl::vector_c) is the same as the…
olpa
  • 1,167
  • 10
  • 28
1
vote
1 answer

boost::mpl::string size error messages

Here is the smaller version of a use case that I am working on. #ifndef BOOST_MPL_LIMIT_STRING_SIZE # define BOOST_MPL_LIMIT_STRING_SIZE 64 #endif #include #include using str =…
Recker
  • 1,915
  • 25
  • 55
1
vote
1 answer

How to use nested metafunctions in Boost.MPL?

I have a simple metafunction: template using is_const_lvalue_reference = mpl::and_< std::is_lvalue_reference, std::is_const::type> >; Apparently, it doesn't work if T is an MPL placeholder…
lizarisk
  • 7,562
  • 10
  • 46
  • 70
1
vote
0 answers

Get subset of fusion::set with types from mpl::vector

Given a fusion::set and an mpl::vector, what's the easiest way to obtain a view of the set with types specified by the vector? Is there some built-in way to do it without manually writing index sequence etc?
lizarisk
  • 7,562
  • 10
  • 46
  • 70