Questions tagged [boost-fusion]

Boost.Fusion is a library for working with heterogenous collections of data, commonly referred to as tuples.

Boost.Fusion is a library for working with heterogenous collections of data, commonly referred to as tuples. A set of containers (vector, list, set and map) is provided, along with views that provide a transformed presentation of their underlying data. Collectively the containers and views are referred to as sequences, and Fusion has a suite of algorithms that operate upon the various sequence types, using an iterator concept that binds everything together.

219 questions
27
votes
4 answers

Boost Fusion articles, examples, tutorials?

Do you know any good resources/articles/examples of boost::fusion library usage? Boost Fusion looks extremely interesting, I think I understand how it works and how to use the basics, but I'm looking for some resources that show any interesting…
stefanB
  • 69,149
  • 26
  • 113
  • 140
13
votes
5 answers

Boost.Fusion run-time switch

I am reading the type of an object from a file: enum class type_index { ... }; type_index typeidx = read(file_handle, type_index{}); Depending on the type index, I want to create a type (out of a list of possible types), and do something generic…
gnzlbg
  • 6,587
  • 3
  • 46
  • 94
12
votes
1 answer

Accessing boost fusion map field name

I've been trying to use some of the boost fusion stuff to write a regular c struct to file. An XML file seems a good way to capture the data and make it compatible with other tools or hand editable. It seems like I almost have it but something…
Chris
  • 121
  • 5
10
votes
4 answers

Haskell equivalent of Boost.Fusion

I have been playing with creating a fully typed DSEL in Haskell using GADTs and such for a fully type-safe AST, and it seems that doing a correctly typed compiler requires constructs such as maps from Haskell types to both types and values (typed…
Jeremiah Willcock
  • 27,461
  • 5
  • 68
  • 75
10
votes
2 answers

Difference between boost::MPL and boost::fusion

I'm new to boost::fusion and boost::mpl libraries. Could anyone please tell me the main difference between these two libraries? Until now I used only fusion::vector and few other simple things. Now I want to use fusion::map or MPL::map but I don't…
Ludek Vodicka
  • 1,381
  • 1
  • 10
  • 30
9
votes
1 answer

BOOST_FUSION_ADAPT_STRUCT doesn't take the right number of arguments

I am using Boost::Spirit to parse some text into structs. This requires using BOOST_FUSION_ADAPT_STRUCT for parsing text and directly storing into the structure. I know that the macro takes 2 arguments: the structure name as the 1st arg and all the…
Nik
  • 283
  • 5
  • 13
9
votes
3 answers

Boost::Spirit::Qi. How to turn inlined parser expressions into standalone grammars, and how to unpack the tuples generated by them?

I'm using QI and Phoenix, and I want to write a small grammar that returns 4 bools which are to be used as arguments for a function call inside a semantic action. I have several functions that need those things, and so far I have used this…
Erius
  • 991
  • 7
  • 21
9
votes
1 answer

How to find an element in a boost::fusion::vector at runtime?

I have here a proprietary implementation of a generic state machine that uses a std::tr1::tuple as a transition table: template struct transition {...}; typedef std::tr1::tuple< transition<…
sbi
  • 204,536
  • 44
  • 236
  • 426
9
votes
1 answer

Spirit Qi attribute propagation issue with single-member struct

I have an compilation issue with Spirit Qi where it complains that value_type is not a member of identifier. For some reason, Qi's attribute system considers identifier to be a container type, and tries to enumerate it's value type. This is a…
namezero
  • 1,951
  • 3
  • 19
  • 35
9
votes
2 answers

C++ iterate into nested struct field with boost fusion adapt_struct

Two stackoverflow answers suggest the approach using fusion adapt_struct to iterate over struct fields. The approach looks nice. However, how do you iterate into a field which itself is a struct? Following the previous answers, I come up with the…
8
votes
1 answer

Flatten a sequence of sequences (of sequences)

I'm using boost::fusion. Lets say I have something like the following: make_vector(1, make_vector('b', 3, make_vector(4, 5.5), "six"), 7, 8) I want to produce an function f such that f(make_vector(1, make_vector('b', 3, make_vector(4, 5.5), "six"),…
Clinton
  • 20,364
  • 13
  • 59
  • 142
8
votes
2 answers

Limits of BOOST_FUSION_ADAPT_STRUCT

I have tried to play with the BOOST_FUSION_ADAPT_STRUCT macro and tried some naive things such as use Fusion to print any arbitrary structure. Starting from this example code given in the documentation, I was unable to perform on my adapted…
Laurent
  • 772
  • 4
  • 15
8
votes
1 answer

How to iterate over boost::fusion associative struct and access in a generic way the keys

This is my very first question into this great knowledge exchange and I hope I find some help. I try to implement a generic way to create PrintTo functions (later to be used in GoogleTest). So the following code does just half of the job. It only…
Felix Petriconi
  • 655
  • 5
  • 11
7
votes
1 answer

Boost Fusion Types offsetof

I'm currently trying to calculate an offset of a data member in a boost fusion adapted structure, but I am not sure if there is an elegant way to do so. I'd like to do something like the following: #include #include…
user985030
  • 1,357
  • 1
  • 15
  • 29
7
votes
1 answer

Adapt class containing a string member as synthesized attribute

I’m trying to parse a character string into an attribute of a custom type symbol, which contains a std::string member. I thought I could use BOOST_FUSION_ADAPT_STRUCT here but that doesn’t work. If I declare the rule as rule
Konrad Rudolph
  • 482,603
  • 120
  • 884
  • 1,141
1
2 3
14 15