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

C++ Register class member var's at compile time

I try to implement a Java-Like annotation system using boost MPL and fusion. Why is it needed: I need to annotate member var's to have some special runtime features. I register try them at compile time to my base clase like this: class foo { …
Matyro
  • 151
  • 1
  • 9
1
vote
1 answer

In boost MPL, how do I check if an operation worked as intended?

Normally when I write code, I frequently check that what I am doing works but using some sort of assertion operation: std::vector a(1, 1); std::vector b = {1}; assert(a == b); // this either works, or breaks in a helpful manner How do I…
quant
  • 21,507
  • 32
  • 115
  • 211
1
vote
0 answers

Preprocessor: convert macro parameter to multicharacter literal

In a nutshell: It's possible to convert macro parameter to character string literal (that contains the spelling of the preprocessing token sequence for the corresponding argument, regarding to 16.3.2, n3797) with # operator. Is there a way, some…
grisha
  • 1,247
  • 1
  • 14
  • 20
1
vote
1 answer

C++: Boost.MPL equivalent for calling a function on the i-th type in a type vector

I have designed a function like this: template class TMapper, class TResult = void, class TUserContext> static typename TResult mapParam(int index, TUserContext ctx) It takes a TMapper, which needs to conform to the following…
thesaint
  • 1,253
  • 1
  • 12
  • 22
1
vote
0 answers

Iterate over a c++14 tuple with a lambda by using boost::mpl::for_each

Is it possible to iterate over a tuple with a lambda using boost::mpl::for_each? MPL documentation creates a separate class away from the call size which iterates over types given to for_each, can a lambda be used instead? Or can the separate class…
user3493721
  • 185
  • 6
1
vote
1 answer

Conditional Compile-time Type mapping based on template parameter

How do I in compile time check if a template parameter has a particular enum and if that is true get that enum value. I am looking for some thing like this for a template parameter T which may ( or may not) have an enum type NeedsToAlign…
iNFINITEi
  • 1,504
  • 16
  • 23
1
vote
1 answer

Detecting at compile-time whether a class has a member variabe or function

I'm trying to detect at compile time whether a class Foo or Bar has either the variable value or member variable initValue(). struct Foo { static const int value; static int initValue(); }; struct Bar { }; I've found several boost and…
Olumide
  • 5,397
  • 10
  • 55
  • 104
1
vote
3 answers

How do I specialize a templated class for data type classification?

We use boost - so using that library should be fine. But I've never managed to wrap my head around creating a set of templates which give you the right specialization for a whole class of data types, as opposed to specializing for a single data type…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
1
vote
1 answer

Simple MPL-like type map template

I am trying to find an elegant way to implement something like a very simple boost::mpl type map. Using MPL or any other boost library is not an option in my context. Besides, the only operations I really need are initialization and lookup. Storing…
Martin J.
  • 5,028
  • 4
  • 24
  • 41
1
vote
0 answers

Can a boost::mpl::list be too long?

My application requires that 100 - 200 event handler classes be instantiated (and registered) for each device that our codebase supports. My idea is to place these handlers in a list like so typedef mpl::list< HandlerFoo, …
Olumide
  • 5,397
  • 10
  • 55
  • 104
1
vote
2 answers

Delegating to boost::function with arbitrary signature

I'm trying to create something like a boost::function, but with an extra 'smart handle' tucked inside, which controls the lifetime of a resource the functions needs to execute correctly. If I didn't need the function signature to be completely…
thehouse
  • 7,957
  • 7
  • 33
  • 32
1
vote
0 answers

c++98 / SFINAE: How to detect if a derived class has its destructor declared in private?

How to detect if a derived class has its destructor declared private? I'm trying to use a SFINAE trick to detect if the destructor is accessible but I keep being failing. I took a look at boost type traits and I did not find any…
Gb01
  • 1,173
  • 3
  • 9
  • 10
1
vote
2 answers

boost::mpl for_each with normal 'C' Array

Using boost::mpl, I can create a typedef of a three element vector like follows: typedef boost::mpl::vector_c height_t; I can pull the values out of this typedef with the following snippit: std::vector
Tom Brinkman
  • 65
  • 1
  • 8
1
vote
1 answer

boost::mpl::set thinks remove_cv::type != T

So I'm trying to get a unique list of types, and I want to get rid of all const duplicates that the list I'm passed might contain. I think the following code should work, but my_set contains "int" two times. What am i doing wrong? #include…
aTMsA
  • 13
  • 2
1
vote
1 answer

boost::mpl::apply only works with typed template args

The boost::mpl::apply metafunction only works with template type arguments. For instance, the following works: using namespace boost::mpl; template struct Bar { }; using BarInt = apply, int>::type; However, if I…
Barry
  • 286,269
  • 29
  • 621
  • 977