--- João Abecasis
Lucio Flores wrote:
So as an exercise, I'm trying to use a lambda expression that applies the first argument twice on it's second argument.
typedef mpl::apply<_1, mpl::apply<_1, _2>::type>::type twice_type;
Then I instance this lambda function on boost::add_pointer and int
typedef mpl::apply
, int>::type result_type; But using boost::is_same, I've found that result_type==int, not int** as expected. Can someone see why?
If you look closely, as it is defined, twice_type is actually the same as mpl::_2. Once you "invoke" the ::type member typedef you're evaluating the metafunction and no longer have a lambda.
Ah.... ok so to create a proper lambda metafunction, I'm typing:
typedef mpl::apply<_1, mpl::apply<_1, _2> > twice_type;
Then to invoke it, I tried doing
typedef mpl::apply
Here's a simple function I find useful in debugging template meta-code:
template <class type> inline void print() { class _ { _() {} }; _ printer; }
I see, I'm supposed to read the type description from the compiler error. Slick!! But the compiler doesn't describe the full description: prog_3_6.cpp: In function `void print() [with type = result_type]': prog_3_6.cpp:32: instantiated from here prog_3_6.cpp:9: error: `print()::_::_() [with type = result_type]' is private gcc version 3.3.5 20050117 (prerelease) (SUSE Linux) Maybe a compiler flag is needed to make it describe the full type? ------------------------------------------- Manson: My philosophy is: Don't think. I don't believe in the mind that you think with and scheme with. I don't believe in words. Reporter: If you don't believe in words, why do you use so many of them? Manson: Words are symbols. All I'm doing is jumbling the symbols in your brain. Everything is symbolic. Symbols are just connections in your brain. Even your body is a symbol. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com