Skip to main content
Filter by
Sorted by
Tagged with
3 votes
2 answers
779 views

Using boost msm state machine with more than 50 transitions

MSMs transition table uses a mpl::vector. The default maximum size is 20. You can change the size with #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS #define BOOST_MPL_LIMIT_VECTOR_SIZE 50 ...
Darragh's user avatar
  • 119
0 votes
1 answer
49 views

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 ...
Tom's user avatar
  • 1,262
1 vote
0 answers
38 views

question about using mpl::range_c with mpl::fold

i have below simple function to convert a mpl::vector<...> to pack<...> namespace mpl = boost::mpl; template <typename... Ts> struct pack{}; struct A{}; struct B{}; template <...
mubcarb's user avatar
  • 161
1 vote
1 answer
261 views

Use the value of strongly typed enum as index in boost::mpl::map

I am using a C++ map structure defined similar to std::map<Foo, std::any> for storing attributes of a compiler symbol table. The Foo is a strongly typed enum, such as enum class Foo {ENUM}. ...
Snow Summer's user avatar
3 votes
3 answers
501 views

Cartesian product of multiple templates

I have a few classes: template <int,char> class Foo{}; template <int,char> class Bar{}; And I want to get all combinations with a few arguments, like this: // {1, 2}, {'a', 'b'} using ...
Igor Pugachev's user avatar
0 votes
2 answers
148 views

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:...
Astris's user avatar
  • 1
0 votes
1 answer
173 views

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 ...
LiviuSandu's user avatar
0 votes
0 answers
97 views

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 ...
Roel's user avatar
  • 19.6k
1 vote
1 answer
227 views

Compile-time Size of Struct Minus Padding

I'm trying to use Boost MPL and Fusion to calculate the size of a struct exclusive of any padding. This is my current best attempt: Live example template<class T> constexpr std::size_t ...
bhillam's user avatar
  • 191
2 votes
2 answers
161 views

How to transform Parameter Pack into something else than std::tuple?

It is better explained by an example: template <typename T1, typename T2> struct OnePair { using TupleOfArgs = std::tuple<T1, T2>; using TupleOfPairs = std::tuple<std::pair<...
Gils's user avatar
  • 633
0 votes
1 answer
237 views

Does std::variant provide functionality similar to boost::variant<>::types?

boost::variant exposes its list of variant types via boost::variant<>::types, which can be conveniently used with boost::mpl::for_each. std::variant is missing such a member. I see std::...
Braden's user avatar
  • 1,507
0 votes
1 answer
158 views

Boost 1.61 header is trying to redefine mpl_::bool_

I'm on Boost 1.61 and compiling with clang 4.0.1 and I'm compiling for linux-gnu Previously I was on Boost 1.52 and was not having this issue. Just by changing versions, I'm getting a compiler error ...
user99999991's user avatar
  • 1,411
1 vote
1 answer
119 views

How to expand the content of an mpl::set as template parameters of a function template

I have a function template with a variadic number of template parameters: template <typename T1, typename... Ts> void doSomething() { ... } Furthermore I have an mpl set defined as follows:...
A. Schorr's user avatar
  • 121
0 votes
1 answer
1k views

Replacing Boost MPL containers with C++17 features

I have some old code based on MPL containers, using enable_if to to activate some dispatch like this: typedef boost::mpl::vector<std::int16_t, std::int32_t, int64_t, float, double, std::complex<...
Matthieu Brucher's user avatar
1 vote
0 answers
42 views

Will translation units built with different FUSION_MAX_VECTOR_SIZE (and similar) be linkable with each other?

I work on a large computational project that heavily use boost::mpl and boost:fusion on C++11. Sometimes, in order to get some translation units to compile, I have to define the following BOOST ...
Adam Ryczkowski's user avatar
0 votes
2 answers
956 views

C++ map key to object

Hi is there a container where a key is a typename and value is an object/instance in boost or std??? What I want to achieve is I have a object pool for each data type and when I want to construct ...
Martin Kosicky's user avatar
3 votes
2 answers
223 views

Obtain regular MPL list from push_front operation

I am using Boost.MPL, I have a compile-time list (boost::mpl::list). When I push back an element, I get something that is probably equivalent to a list but is not an boost::mpl::list. #include <...
alfC's user avatar
  • 16.1k
4 votes
1 answer
254 views

Boost MPL Sorting Template Parameter Pack

The problem I'm trying to solve is to sort a template parameter pack according to the return value of a constexpr templated function specialized for each of the types I'm sorting. I have a list of ...
user3831357's user avatar
0 votes
1 answer
65 views

MPL Map Instantiate Type

I have the following: class Message { public: bool process() { return doProcess(); } protected: virtual bool doProcess() = 0; }; class Hello : public Message { protected: ...
joshu's user avatar
  • 463
-1 votes
1 answer
237 views

boost multi index convert index to tag and loop on indexes

I have a template class(CrMultiIndex) that receive a template parameter a definition of boost multi index(GlobalHash).I work with c++14 I need a way to translate index to tag(n_to_tag)? And to loop ...
yaron's user avatar
  • 383
1 vote
1 answer
80 views

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 <...
Quentin's user avatar
  • 63k
1 vote
1 answer
118 views

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<T1, T2, T3, T4> list_type; For some known types T1, T2, T3, T4. Is there any way to use metaprogramming to ...
Jason R's user avatar
  • 11.6k
1 vote
1 answer
214 views

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 ...
Tarc's user avatar
  • 3,312
1 vote
1 answer
2k views

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 ...
Andy's user avatar
  • 137
0 votes
1 answer
240 views

boost MPL - doing transform on joint_view

Consider: template<typename T> struct MakeVectorOfType { typedef std::vector<T> type; }; typedef boost::mpl::vector<int, double> TScalarTypes; typedef boost::mpl::transform<...
Roel's user avatar
  • 19.6k
2 votes
1 answer
523 views

Using boost::mpl::find_if with custom predicate

Given struct A {}; struct B {}; struct C {C(B) {}}; struct D : B {}; struct E {operator A() const {return A();}}; struct F {}; using AllowedTypes = boost::mpl::vector<A, C>; I'm trying to ...
Christophe Fuzier's user avatar
1 vote
2 answers
197 views

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<bool, int, double> allowedTypes; class Foo { typedef boost::...
codeJack's user avatar
  • 2,503
1 vote
0 answers
56 views

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 ...
Joe Sunday's user avatar
1 vote
1 answer
283 views

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 ...
Aleph0's user avatar
  • 6,064
5 votes
1 answer
1k views

Getting all base classes [Meta-Programming]

Yesterday faced with problem how to get all base classes from some class. For example: class Object { public: Object() = default; }; class DerivedOne : public Object { public: DerivedOne() ...
Denis Kotov's user avatar
3 votes
1 answer
912 views

How to simplify type generated by make_variant_over

Boost variant has a function called make_variant_over that takes an MPL sequence (for example list<A, B, C>) and produces a variant from those types. However if one looks carefully the type ...
alfC's user avatar
  • 16.1k
3 votes
1 answer
438 views

Classify Types in Boost Variant using Visitor does not compile

I'm using boost-variant throughout my projects. In one scenario I need to classify the types contained in my boost-variant into several classes. As I have quite a lot of types in my variant I came up ...
Aleph0's user avatar
  • 6,064
0 votes
1 answer
98 views

How process knows when to stop listening for receive?

Consider a mesh whose bins are decomposed among processes. The numbers in the image are the ranks of processes. At each time step, some of the points displace so that it is needed to send them to new ...
Shibli's user avatar
  • 6,119
2 votes
1 answer
246 views

How do I merge two mpl maps producing a new map?

However I tweek the following code, there seems to be a point I am missing. It will not compile. I have two maps int -> int. I want to produce a third int -> int map containing all the key-value pairs ...
Øyvind Roth's user avatar
1 vote
0 answers
83 views

Boost MPL push_back all elements in one vector into another [duplicate]

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<Class0, Class1,...
CJCombrink's user avatar
  • 3,940
1 vote
1 answer
879 views

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 ...
Mathieu Van Nevel's user avatar
2 votes
1 answer
471 views

using boost mpl lambda with variadic template class

I am having a hard time understanding why the following simple program won't compile. I have a variadic template class (my_type below) which I want to use to transform an mpl vector. The following ...
linuxfever's user avatar
  • 3,813
1 vote
1 answer
178 views

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 ...
Bojian Zheng's user avatar
  • 2,777
2 votes
1 answer
177 views

boost mpl count for simple example

I am trying to learn boost mpl, tried a very simple example to count the number of times a type appears in mpl map. Could somebody explain why the output of this program is 0 typedef map< ...
user424060's user avatar
  • 1,581
1 vote
1 answer
370 views

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 ...
olpa's user avatar
  • 1,207
2 votes
2 answers
613 views

Boost Fusion: validate adapted struct member ordering at compile time

I'm using BOOST_FUSION_ADAPT_STRUCT(), and I need to check that all the members are declared and in the correct order. So first I did this: template <typename Sequence> struct checker { ...
John Zwinck's user avatar
0 votes
1 answer
283 views

Utilize boost-variant to create generic factory method with boost::mpl::for_each

In one of my projects I needed to map the int of the boost::variant which()-Function to the types of the boost::variant. For some reasons the map doesn't contain the correct TVar Type? Why is that? #...
Aleph0's user avatar
  • 6,064
7 votes
2 answers
2k views

Creating a new boost-variant type from given nested boost-variant type

Assume that I have a nested boost::variant-type TNested containing some types and some other boost::variant types (that itself cannot contain again boost::variant types, so that there will be no ...
Aleph0's user avatar
  • 6,064
5 votes
1 answer
9k views

C++ map of string as key and type as value

Is there an alternative to boost-hana in boost library which will allow me to create something like typedef boost::AlterinativeToHana::map< make_pair<"abcd",ABCDType>, ...
Recker's user avatar
  • 1,975
2 votes
3 answers
1k views

Get boost::variant's type index with boost::mpl

boost::variant has member types which is some kind of boost::mpl structure. Is there a way to get an index of type in that structure at compile time, so late in in runtime i could do if(...
K117's user avatar
  • 118
2 votes
1 answer
709 views

Boost variant visitor with variadic template arguments

In one of my projects I'm actively using boost::variant and I stumbled upon a question I couldn't resolve on my own. I have a boost::variant that might contain atomic datatypes and STL containers of ...
Aleph0's user avatar
  • 6,064
1 vote
1 answer
229 views

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 <boost/mpl/string.hpp> #include <...
Recker's user avatar
  • 1,975
1 vote
1 answer
130 views

How to use nested metafunctions in Boost.MPL?

I have a simple metafunction: template <typename T> using is_const_lvalue_reference = mpl::and_< std::is_lvalue_reference<T>, std::is_const<typename std::remove_reference<...
lizarisk's user avatar
  • 7,800
1 vote
0 answers
48 views

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 ...
lizarisk's user avatar
  • 7,800
4 votes
3 answers
933 views

Determining largest sizeof() in boost variant

Given: boost::variant<T1,T2,T3,...,TN> Calculate the following at compile time: max(sizeof(T1), sizeof(T2), sizeof(T3),... ,sizeof(TN)) I had no idea how to approach this, but this answer ...
Matt K's user avatar
  • 618

1
2 3 4 5 6