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.

222 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
  • 77,323
  • 27
  • 116
  • 141
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
  • 7,135
  • 5
  • 53
  • 106
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
11
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,610
  • 1
  • 18
  • 33
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
  • 30,161
  • 7
  • 76
  • 78
10
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
  • 293
  • 5
  • 14
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
  • 1,021
  • 8
  • 21
9
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
  • 812
  • 5
  • 15
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
  • 219,715
  • 46
  • 258
  • 445
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
  • 2,203
  • 3
  • 24
  • 37
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
  • 22,361
  • 15
  • 67
  • 163
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
  • 675
  • 5
  • 11
7
votes
3 answers

Accessing members in a C++ struct both dynamically and statically

I would like to have a struct (or something similar) in C++, that will allow access to its members dynamically. It should have a generic getter and setters that receive the member name as a string, and return some sort of variant type (e.g.…
haggai_e
  • 4,689
  • 1
  • 24
  • 37
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,557
  • 1
  • 16
  • 32
1
2 3
14 15