Boost logo

Boost Users :

Subject: [Boost-users] Need help with Errors in boost MPL tutorials
From: Linh Ha (lha_at_[hidden])
Date: 2012-01-23 21:03:40

Dear all,

I try to learn Meta-programing but i got stuck with lambda meta-function
and place holder.
I try to compile very simple program

#include <boost/bind.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/type_traits.hpp>

template <class F, class X>
struct twice : F::template apply<typename F::template apply<X>::type > {

template <class X>
struct two_pointers
: twice<typename boost::mpl::lambda<boost::add_pointer<_1> >::type, X>
int main(int argc, char** argv) {
return 0;

It is from the boost tutorial
. But it can not be complied. The error messages are

main.cpp:21: error: type/value mismatch at argument 1 in template
parameter list for ‘template<class T> struct boost::add_pointer’
main.cpp:21: error: expected a type, got ‘<unnamed>::_1’
main.cpp:21: error: template argument 1 is invalid
main.cpp:21: error: template argument 3 is invalid
main.cpp:21: error: template argument 1 is invalid
main.cpp:22: error: expected ‘::’ before ‘{’ token
main.cpp:22: error: expected class-name before ‘{’ token

I use

g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5

I have no idea what happened. Any inside would be appreciated. It is
important I think since lambda is used all over place with MPL.

Linh Ha

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at