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.
44
questions
1
vote
0answers
37 views
How to use boost::proto to connect slots to signals
I'm trying to create an embedded language to connect slots to member signals. I've looked at the examples and tutorials on the boost website but I'm still completely lost and I'm not even sure if what ...
3
votes
1answer
438 views
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....
1
vote
0answers
66 views
Evaluating proto expression tree
I am trying to evaluate a proto expression tree with a custom defined context. I have a struct exp_tag {} using which a create a terminal
template <typename T>
inline typename proto::result_of:...
2
votes
0answers
155 views
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<unknown>
,...
2
votes
0answers
88 views
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 ...
2
votes
1answer
47 views
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().
...
1
vote
1answer
64 views
Matching operator somewhere in Proto expression
Why doesn't the following Boost.Proto grammar match dereference operator, and what's the
correct way to do this?
#include <iostream>
#include <boost/proto/proto.hpp>
namespace proto = ...
1
vote
0answers
61 views
Using a derived class as terminals in Boost.proto
Suppose you'd want to implement a simple EDSL (Embedded Domain Specific Language) with Boost.proto with the following requirements:
Custom class 'Vector' as terminal
Classes derived from 'Vector' are ...
4
votes
1answer
171 views
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 <iostream>
#include &...
3
votes
1answer
186 views
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 ...
3
votes
1answer
3k views
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 ...
3
votes
1answer
45 views
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::...
2
votes
2answers
825 views
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 ...
5
votes
1answer
133 views
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 ...
1
vote
1answer
415 views
Boost.Proto: General class layout for an EDSL with custom terminal classes
In order to familiarize myself with Boost.Proto I am trying to build yet another expression template library for floating-point vectors of fixed but arbitrary size by adapting the TArray example from ...
1
vote
1answer
334 views
Is it possible to build and incrementally evaluate/mutate expression trees in Boost.Proto?
Is it possible to extract parts of a Boost.Proto expression tree, evaluate them individually (externally), and then mutate the expression tree, replacing the extracted parts with a result?
In my ...
6
votes
2answers
1k views
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 ...
1
vote
0answers
1k views
How to parse DSL input to high performance expression template
(EDITED both title and main text and created a spin-off question that arose)
For our application it would be ideal to parse a simple DSL of logical expressions. However the way I'd like to do this is ...
4
votes
1answer
284 views
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 ...
1
vote
1answer
229 views
Obtaining the tag type of a Boost Proto child expression
Of a Boost Proto expression, when should I not expect a proto_tag member? I can enquire regarding the tag type of a placeholder, say, using either of the following methods:
typedef proto::tag_of<...
0
votes
1answer
132 views
Variable hiding within nested let blocks in Boost Phoenix
I'm having some trouble with nested let blocks in Boost Phoenix when an "inner" local variable hides an "outer" local variable. Even with the "Visibility" example from the documentation here, shown ...
2
votes
2answers
403 views
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 ...
1
vote
1answer
182 views
Non-intrusively replacing a custom type with an expression tree
I'm trying to introduce lazy evaluation into an existing code project. The project core basically consists of a large amount of calculations using a custom type (it acts like a double but does ...
5
votes
2answers
321 views
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 <class T1, ...
3
votes
1answer
291 views
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 <&...
5
votes
1answer
400 views
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 ...
1
vote
1answer
312 views
Displaying a Flattened Phoenix Expression using Boost Fusion
Following the Expressions as Fusion Sequences section of the Proto User Guide, I get to the point where I iterate over a flattened proto expression: _1 + 2 + 3 + 4:
#include <iostream>
#include ...
5
votes
1answer
541 views
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 ...
1
vote
0answers
488 views
User defined arguments in Boost Phoenix
The Boost Phoenix documentation here indicates that I can create my own (lambda) arguments instead of _1/arg1, _2,arg2 etc. So, starting with code like this:
#include <iostream>
#include <...
2
votes
0answers
205 views
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 ...
5
votes
1answer
245 views
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 ...
2
votes
1answer
369 views
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 ...
3
votes
1answer
234 views
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 <class T> ...
5
votes
1answer
492 views
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 ...
4
votes
1answer
188 views
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 ...
1
vote
1answer
140 views
Non-default constructed boost::proto terminal
I'm trying to define a very limited parser combinator library using boost::proto and was wondering if it's by any means possible to define a non-default constructed proto terminal.
I have a structure ...
8
votes
1answer
922 views
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 ...
2
votes
3answers
544 views
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< ...
6
votes
1answer
344 views
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 <typename Ret, typename A0, typename A1, Ret func(A0,A1)>
struct apply_func : proto::...
3
votes
1answer
205 views
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::_ > >
{};
...
4
votes
0answers
269 views
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 ...
1
vote
1answer
528 views
How to make a boost-proto function expression streamable?
I'm going over the boost-proto tutorial, and ran into this problem with the lazy pow function example. This is the example code:
// Define a pow_fun function object
template<int Exp> // , ...
4
votes
2answers
234 views
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 ...
10
votes
2answers
759 views
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 <...