Questions tagged [boost-proto]

Boost.Proto is a framework for building Domain Specific Embedded Languages in C++. It provides tools for constructing, type-checking, transforming and executing expression templates.

Proto is a framework for building Domain Specific Embedded Languages in C++. It provides tools for constructing, type-checking, transforming and executing expression templates[2]. More specifically, Proto provides:

  • An expression tree data structure.
  • A mechanism for giving expressions additional behaviors and members.
  • Operator overloads for building the tree from an expression.
  • Utilities for defining the grammar to which an expression must conform.
  • An extensible mechanism for immediately executing an expression template.
  • An extensible set of tree transformations to apply to expression trees.

Boost.Proto Documentation can be found here

44 questions
10
votes
2 answers

Matching a Boost.Proto grammar to a type

I'm trying to make a grammar in Boost.Proto that matches a vector type, but when I give it a terminal of that type, it doesn't match the grammar. The type definition looks like this: template struct vector { typedef T…
vedosity
  • 720
  • 4
  • 15
8
votes
1 answer

Static functions from boost.lambda or boost.phoenix

I regularly use boost.lambda (and phoenix) to define lambda functions in C++. I really like their polymorphic property, the simplicity of their representation and the way they make functional programming in C++ so much easier. In some cases, it's…
enobayram
  • 4,650
  • 23
  • 36
6
votes
1 answer

How do I write a proto transform templated by a function?

I would like to reuse code by writing a proto transform which is templated by a function pointer: template struct apply_func : proto::callable { // Do something with func }; However, the…
Irit Katriel
  • 3,534
  • 1
  • 16
  • 18
6
votes
2 answers

Constructing Eigen expression templates with Boost.Proto

I'd like to use Boost.Proto to transform an embedded domain-specific language into a series of matrix operations implemented with the Eigen library. Since efficiency is important, I want proto to generate Eigen expression templates and avoid…
zrnzvxxy
  • 325
  • 1
  • 9
5
votes
1 answer

How to wrap multiple function overloads with a generic TR1 function object?

I have a function foo() that is being provided in a library context. The library defines a handful of overloads for this function, like: char foo(float x, int y); short foo(double x, char y); (I made the above argument/result types up. The takeaway…
Jason R
  • 11,159
  • 6
  • 50
  • 81
5
votes
2 answers

Can I stringify a Boost Phoenix expression?

Can I convert a Boost Phoenix expression into a representative string of C++? I could have: stringify(_1<_2); which might then produce a string containing something like: template struct foo { auto operator()(T1 x1, T2 x2) …
user2023370
  • 10,488
  • 6
  • 50
  • 83
5
votes
1 answer

Transforming Function Bodies within Boost Phoenix Expressions

How can I also include function bodies in a transformation of a Boost Phoenix expression? For example, I have built on the Lazy Functions section of the Boost Phoenix Starter Kit, and created a lazy addition function: struct my_lazy_add_impl { …
user2023370
  • 10,488
  • 6
  • 50
  • 83
5
votes
1 answer

Transforming a Boost C++ Phoenix Expression Tree

In the Boost Phoenix article, "Transforming the Expression Tree", here, a set of specialisations of a custom invert_actions class, are used to invert binary arithmetic expressions. For example a+b becomes a-b; a*b becomes a/b; and vice versa for…
user2023370
  • 10,488
  • 6
  • 50
  • 83
5
votes
1 answer

Why does this proto/phoenix toy example crash?

I am experimenting with proto and phoenix and what is one of my first toy examples crash and I have no idea where I should be looking at. Since someone on the #boost IRC channel told me to ensure that the phoenix expression tree is first deep copied…
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
5
votes
1 answer

boost.proto + modify expression tree in place

Background question: boost.proto + detect invalid terminal before building the expression tree. Hi, what i'm trying to achieve is create a copy of an expression tree, where all vectors are substituted with their begin iterators (in my case is a…
Giuliano
  • 640
  • 3
  • 15
4
votes
0 answers

How can I determine the type returned by eval on proto expression?

I defined a context for my grammar which is templated on the input types, something like the snippet below. I am missing the types where the ???? are. Before I start writing recursive templates to figure them out, is there anything in proto already?…
Irit Katriel
  • 3,534
  • 1
  • 16
  • 18
4
votes
2 answers

How to determine what compiler does with a metaprogram? (for boost.proto)

How do I determine what my compiler (g++) is doing with template code? I am using boost.proto (an expression-template library) to evaluate some maths expressions at compile time. The code evaluates the expressions correctly, but I would like to see…
Tom
  • 5,219
  • 2
  • 29
  • 45
4
votes
1 answer

boost::proto::is_aggregate returning false when it is an aggregate type

While testing out aggregate types I tried using boost::proto::is_aggregate in order to check if the types that I'm creating are truly aggregate. I wrote this code: #include #include struct IsAggregate { …
Michael Kiros
  • 563
  • 4
  • 11
4
votes
1 answer

Obtaining the types of local variables in Boost Phoenix

How can I obtain the types of the local variables used within a scoped Boost Phoenix statement? Using Phoenix and Proto I can extract numerous aspects of a Phoenix expression. For example, the following code exposes the arity (3); tag type…
user2023370
  • 10,488
  • 6
  • 50
  • 83
4
votes
1 answer

boost.proto + detect invalid terminal before building the expression tree

I was playing with Boost.Proto, mostly for fun and to see if in future I could make some use of it in my own projects. That said, as probably most beginners of this library, i've played with a modified version of the 'lazy vector' example, but using…
Giuliano
  • 640
  • 3
  • 15
1
2 3