When I try the mpl::bind function with following test code, I failed to pass compiler in gcc, could someone help me to track out the problems, many thanks.
#include <iostream>
#include <typeinfo>
#include <string>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/char.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/arg.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/quote.hpp>
using namespace std;
using namespace boost::mpl;
template< typename T1,typename T2 >
struct int_plus:boost::mpl::int_< (T1::value+T2::value) >
{
};
int main()
{
typedef boost::mpl::lambda< int_plus<_1, _2 > >::type test1; //-fine
// test2 define is causeing error
typedef boost::mpl::bind < int_plus<_1, _2 > > test2; //-error?
typedef boost::mpl::lambda< quote2<int_plus>, _2, _1 >::type test3; //-fine
typedef boost::mpl::bind< quote2<int_plus>, _2, _1 > test4; //-fine
typedef test1::apply<int_<42>, int_<23>>::type test5; //-fine
typedef test2::apply<int_<42>, int_<23>>::type test6; //-error
typedef test3::apply<int_<42>, int_<24>>::type test7; //-fine
typedef test4::apply<int_<42>, int_<24>>::type test8; //-fine
BOOST_MPL_ASSERT_RELATION( test5::value, ==, 65 ); //-fine
//BOOST_MPL_ASSERT_RELATION( test6::value, ==, 65 );
}
the error message:
||=== Build: Debug in jtest2 (compiler: GNU GCC Compiler) ===|
C:\boost\mpl\aux_\preprocessed\gcc\apply_wrap.hpp||In instantiation of 'struct boost::mpl::apply_wrap0, mpl_::arg<2> >, mpl_::bool_ >':|
C:\boost\mpl\aux_\preprocessed\gcc\bind.hpp|86|required from 'struct boost::mpl::bind0, mpl_::arg<2> > >::apply, mpl_::int_<23> >'| C:\ls\jtest2\main.cpp|30|required from here|
C:\boost\mpl\aux_\preprocessed\gcc\apply_wrap.hpp|20|error: no class template named 'apply' in 'struct int_plus, mpl_::arg<2> >'|
C:\boost\mpl\aux_\preprocessed\gcc\bind.hpp||In instantiation of 'struct boost::mpl::bind0, mpl_::arg<2> > >::apply, mpl_::int_<23> >':|
C:\ls\jtest2\main.cpp|30|required from here| C:\boost\mpl\aux_\preprocessed\gcc\bind.hpp|86|error: no type named 'type' in 'struct boost::mpl::apply_wrap0, mpl_::arg<2> >, mpl_::bool_ >'|
||=== Build failed: 2 error(s), 5 warning(s) (0 minute(s), 0 second(s)) ===|
test4
solve the issue you've got withtest2
? – Igor R.