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

Template specialization on typename parameter being any instantiation of a particular template

I have a class template Z that I would like specialize when passed a type that is an any instantiation of a particular template N: struct L { template void foo(S &) {/*...*/} }; template struct M { template
Jeff
  • 3,475
  • 4
  • 26
  • 35
1
vote
2 answers

Boost Metafunction class higher order function

What's the difference between metafunction classes and placeholders and higher order functions?
Blair Davidson
  • 901
  • 12
  • 35
1
vote
1 answer

C++ Compile-Time Conditional Run-Time Statements

Is there a way to, at compile-time, decide on one of two run-time code paths? I am aware that function overloading can be used to accomplish this feat, but then the code size increases because both of my functions are compiled and linked into the…
Mukul M.
  • 540
  • 1
  • 5
  • 15
0
votes
2 answers

MPL-like vector with variadic templates: Insertion

I am wondering how one would write a Boost MPL-like vector_c using variadic templates. I already wrote the following snippet of code: template struct vector { typedef vector next; static…
cschwan
  • 3,283
  • 3
  • 22
  • 32
0
votes
1 answer

Optimization of compile time constants

I'm trying to implement a class like std::pair but with more than 2 components. Since in my application it may happen that some of the tuple components are already known at compile-time, i would like to have the following space optimization: when I…
Giuliano
  • 640
  • 3
  • 15
0
votes
0 answers

Boost MPL Sequence and defines: How to turn MPL Sequence into define string?

I understand we can print elements into define one by one knowing total count (pseudocode): // For the sake of simplicity, I assume the Sequence passed is a boost::mpl::vector #define seq_to_array_str \ < typename…
myWallJSON
  • 9,110
  • 22
  • 78
  • 149
0
votes
1 answer

Boost.Variant, Boost.MPL: How to append types?

I look at this grate code based on boost.Any and cant help but wonder if we could use Boost.Variant instead. I wonder if such API would be possible: void voidFunc() { std::cout << "void called" << std::endl; } int stringFunc(std::string…
myWallJSON
  • 9,110
  • 22
  • 78
  • 149
0
votes
1 answer

Getting the first M elements of an mpl vector

I have a boost::mpl::vector with N elements, say: typedef boost::mpl::vector my_vector; I wish to obtain a sequence containing the first M elements of my_vector. So if M is 2 I want out a: typedef…
Freddie Witherden
  • 2,369
  • 1
  • 26
  • 41
0
votes
1 answer

Passing a mpl lambda expression as a template argument

I'm trying to write a metafunction similar to boost::mpl::find_if but with the difference that it will traverse the sequence starting from the end. I am getting compilation errors which I guess come from computation of mpl::lambda passed as an…
Marcin
  • 897
  • 1
  • 7
  • 19
0
votes
2 answers

Using boost mpl pop_front

Having: #include #include #include int main() { typedef boost::mpl::vector v; typedef typename pop_front::type poped; } the problem is that…
smallB
  • 16,662
  • 33
  • 107
  • 151
0
votes
1 answer

Boost metaparse how to return custom types

I'm trying to create a simple parser with metaparse to demonstrate how I can return my own custom types. If I had a custom type ValNum, how can I integrate this into a basic parser such that it is returned by the parser after matching a number?…
Tom
  • 1,235
  • 9
  • 22
0
votes
3 answers

choosing ctor arguments at runtime

Is it possible to address the following scenario of choosing the argument at runtime with mpl? struct A { A(int number) { /* use number */ } }; struct B { }; template struct A_or_B_Holder { A_or_B_Holder() : _t( /* void…
0
votes
2 answers

Using Custom Unary Predicates With boost::mpl::find_if in C++

I have a number of different class types each with the member function GetParameterString() which returns a string specific to the class. I'd like to be able to store these class types in a boost::mpl::list and compare GetParameterString to a test…
Astris
  • 1
  • 1
0
votes
1 answer

Template metaprogramming - trying to implement Dimensional Analysis

For a better understanding and learning, I tried to use the boost mp11 library to implement the Dimensional Analysis from "C++ Template Metaprogramming" book (also found in the documentation of boost mpl library). A reason why was that C++11 has…
0
votes
0 answers

Boost mpl - append an element for each element in a vector

I have a boost mpl vector with types in it (obviously). I want to, after declaring this vector, iterate over it and append each type, wrapped in another template, to that vector. I have tried many things but for the life of me I can't figure this…
Roel
  • 19,338
  • 6
  • 61
  • 90