Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-13 12:31:24


AMDG

Matt Brown wrote:
> I just tried to build this code in visual studio 2005, and got error:
>
> error C3201: the template parameter list for class template
> 'boost::mpl::bind2<F,T1,T2>::apply' does not match the template
> parameter list for template parameter 'boolfunc'
>
> This code works fine with gcc, and boost mpl portability page
> (http://www.boost.org/libs/mpl/doc/tutorial/portability.html) says my
> version of visual studio should be able to compile this. However, it
> appears to think the lambda< ... >::type::apply is not
> a metafunction. Any help will be greatly appreciated.
>
> -Matt Brown
>
>
>
> #include <iostream>
> #include <boost/mpl/lambda.hpp>
> #include <boost/type_traits/is_same.hpp>
> #include <boost/mpl/placeholders.hpp>
>
> template <template <typename> class boolfunc>
> class test
> {
> public:
> static void print()
> {
> if(boolfunc<int>::type::value)
> {
> std::cout << "int: true\n";
> }
> }
> };
>
> int main(void)
> {
> test<
> boost::mpl::lambda<
> boost::is_same<boost::mpl::_1, int>
> >::type::apply
> >::print();
> };

Don't do that.

boost::mpl::lambda<
                       boost::is_same<boost::mpl::_1, int>
>::type::apply<int>::type

will work, but apply actually takes extra default arguments and thus cannot
be bound to a template template argument.

i.e. (For exposition only)

template<class T>
struct lambda {
    struct type {
        template<class T0 = na, class T1 = na, ...>
        struct apply {
            typedef /unspecified/ type;
        };
    };
};

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net