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
3
votes
1 answer

Can I know the type of what matched boost::proto::_ in a transform?

In the boost::proto manual, there is an example of a grammar that matches terminals of type std::transform<...>: struct StdComplex : proto::terminal< std::complex< proto::_ > > {}; I would like to write a transform that does something with the…
Irit Katriel
  • 3,534
  • 1
  • 16
  • 18
3
votes
1 answer

Compilation error by switching to higher Boost Version 1.6.1

I switched my Boost version from 1.6.1 to >=1.6.2 and my boost::spirit parser code fails to compile. Actually, I thinking the problem has something to do with a bug fix in Boost Variant from version 1.6.1 to version 1.6.2. Release notes of version…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
3
votes
1 answer

Boost.Proto : Is it possible for Proto transforms to evaluate a mixture expression of matrix & vector?

Now I am trying to teach g++ compiler linear algebra so that g++ can rewrite an expression such like (matrix * vector)(index) as the loop for evaluating the expression. Basically this is what I expect as a next article of the last article in the…
mito
  • 111
  • 8
3
votes
1 answer

Writing a DSL in C++ with boost::proto

Apologies for asking such an open-ended question, but I want to emulate some synthetic assembly (not for a real processor) in C++ and I want to decouple the assembly from the implementation of the simulator it runs on. Writing a DSL or similar seems…
adrianmcmenamin
  • 1,081
  • 1
  • 15
  • 44
3
votes
1 answer

How can I add parent references to Boost.Proto expressions?

I want to generate expression trees that have "reverse" references from child to parent. Is there a way to customize the Proto generator or domain so that the expression wrapper class (using proto::extends<>) contains a reference to the parent…
Aaron
  • 594
  • 2
  • 12
3
votes
1 answer

Subscript operator[] error with Boost C++ Phoenix user-defined argument

With an existing Boost Phoenix (placeholder) argument, such as _1, I can use the array/subscript operator. For example, the following excerpt will display a 1. int arr[4] = {1,2,3,4}; std::cout << _1[0](arr) << std::endl; However, if I define my…
user2023370
  • 10,488
  • 6
  • 50
  • 83
3
votes
1 answer

boost.proto + unwrap expression from domain-specific expression wrapper

Background question: boost.proto + modify expression tree in place Hi, consider the following transform to extract the value_type from a vector_expr (see previous questions) template struct value_type_trait; template
Giuliano
  • 640
  • 3
  • 15
2
votes
0 answers

Symbolic differentiation using boost proto

I am trying to build an EDSL that can handle symbolic differentiation. I'm having trouble when it comes to function. struct Derivative : or_< when< terminal , boost::mpl::int_<1>() > , when< terminal<_> …
2
votes
0 answers

Can Boost Proto adapt structures to a getter setter type API

This seems like a common problem. I've got two massive sets of code that need to be glued together: one that uses simple structs to hold data, the other has APIs that only expose getter/setter methods. Is it possible to use Boost.Proto to define a…
Grisby_2133
  • 487
  • 2
  • 11
2
votes
1 answer

Non-proto objects as terminals

I would like to use instances of a non-proto class as proto terminals for all purposes. To enable this functionality, I use is_terminal metafunction and pass it to BOOST_PROTO_DEFINE_OPERATORS(). This actually defines the operators, so the following…
Igor R.
  • 14,716
  • 2
  • 49
  • 83
2
votes
2 answers

Boost.Proto : How to make an expression terminal of a primitive array instead of std::vector?

Now I am trying to make yet another mini-EDSL (embedded domain-specific language) for vector expressions. Actually Boost.Proto users' guide already provided such an EDSL example, "Lazy Vector", where vector expressions are made of std::vector.…
2
votes
2 answers

Templating a Simple Boost Proto C++ Expression Evaluator

I'd like to build on the Boost Proto "Unpacking Expressions" example from here by using a template parameter to specify the return type of the do_eval transform (hitherto double). For brevity I'll present a working, simplified (plus-only) version of…
user2023370
  • 10,488
  • 6
  • 50
  • 83
2
votes
0 answers

How to use a non-polymorphic lambda in Boost Proto/Phoenix?

I'd like to provide an API which accepts a user-defined Boost Phoenix lambda. Unlike a C++11 lambda, a Phoenix lambda is polymorphic. I am able to use the [] operator of a lambda argument. The following snippet will output the first element of array…
user2023370
  • 10,488
  • 6
  • 50
  • 83
2
votes
1 answer

Boost.Proto and Complex Transform

I'm experimenting with Proto to build a DSEL that operates on geometric vectors. I'm trying to write a transform that would take an assign expression and unroll it component wise. For instance, I want to replace p = q + r; by p[0] = q[0] +…
K-ballo
  • 80,396
  • 20
  • 159
  • 169
2
votes
3 answers

building s-expression with boost::proto

I'm trying to build s-expression objects using boost::proto with the following terminals: typedef proto::terminal< const char* >::type string_term_t; typedef proto::terminal< uint32_t >::type uint32_term_t; typedef…
lurscher
  • 25,930
  • 29
  • 122
  • 185