
Hi Markus, Markus Werle wrote:
Having hard times to catch the ideas of the construct_ example.
First of all: There are 2 typos in the definition of construct:
<snip> Sorry for the typos! Thanks for catching them.
To keep it off the other thread that I will continue later this day:
Could you please remark in the docs with big red letters that make_expr is a type in namespace proto::functional and a function in namespace proto and why name clashes won't appear?
I do not like that naming convention, mainly because I cannot remember the rules for the compiler for cases where both are visible. And yes, if you remember, I like to learn them again - now.
If you bring them both into scope, the names will clash. There shouldn't be a need to ever bring the proto::functional namespace into scope, so there shouldn't be a problem. My approach to free functions in Proto is as follows: For each free function template proto::X, there is a class template proto::result_of::X which calculates the result type of proto::X. (Here I'm following existing practice established by Fusion.) There is also a class or class template proto::functional::X which is the function object equivalent of proto::X. These are provided as a convenience. I've had enough occasions to need them myself that I decided to provide them.
Also for beginners like me it would be nice to have struct construct_ be renamed to constructor. The '_' is easily overlooked at midnight when you print 2 pages on one as I did. And that text is not for the faint-hearted anyway.
Noted.
Note that I'd prefer code repetition in this example: please add definitions for _1 and _2, better: a complete, compilable example, see next section:
Yes, I'll build a complete example around this.
Trouble --------
Below is code that does not compile. I get the impression that this led to the confusion in the other thread: I cannot see how proto::eval drops in in the std::transform call. Please correct the code in order to make it work.
In the construct() section in the docs I say, "Making it work with std::transform() takes a little more effort, but that's covered in the Calc2 example," and I provide a link to the example. Getting std::transform() to invoke proto::eval() involves proto::extends<>, which I haven't talked about yet at that point. A better approach would be to provide a complete working construct() example and provide a link to that. In that spirit, I have added a Lambda example that shows a working construct() in action. HTH. -- Eric Niebler Boost Consulting www.boost-consulting.com