什么Boost :: is_same不起作用?

时间:2017-05-17 11:10:15

标签: c++ boost

我正在编写程序来使用MPL库过滤矢量类型。为此,我在迭代器的帮助下使用了pass。但是,Boost :: is_same不起作用。我的代码:

  template<typename It,typename End,typename T>
    struct Conteins{
        typedef typename boost::mpl::next<It>::type next;
        typedef typename boost::mpl::deref<It>::type values;
        static const bool value=boost::is_same<End,next>::value?false:
                (boost::is_same<T,values>::value?true: Conteins<next,End,T>::value);
    };

呼叫:

typedef boost::mpl::vector<Test1,int,Test2,Test3,char, double,char,double,Test2> vec;
typedef boost::mpl::begin<vec>::type It;
typedef boost::mpl::end<vec>::type End;
cout<<Conteins<It,End,char>::value;

发生编译错误时:

make all 
Building file: ../src/META.cpp
Invoking: Cross G++ Compiler
g++ -I/home/diman-pro/workcpp/boost_1_64_0 -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"src/META.d" -MT"src/META.o" -o "src/META.o" "../src/META.cpp"
In file included from /home/diman-pro/workcpp/boost_1_64_0/boost/mpl/long.hpp:20:0,
                 from /home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/aux_/at.hpp:19,
                 from /home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/vector0.hpp:17,
                 from /home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/vector10.hpp:18,
                 from /home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/vector20.hpp:18,
                 from /home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector.hpp:36,
                 from ../src/META.cpp:11:
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/aux_/integral_wrapper.hpp: In instantiation of ‘struct mpl_::long_<33662l>’:
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/aux_/at.hpp:35:38:   required from ‘struct boost::mpl::v_at_impl<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 894l>’
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/aux_/at.hpp:40:8:   required from ‘struct boost::mpl::v_at<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 894l>’
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/vector/aux_/iterator.hpp:40:44:   required from ‘struct boost::mpl::v_iter<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 894l>’
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/deref.hpp:30:37:   required from ‘struct boost::mpl::deref<boost::mpl::v_iter<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 894l> >’
../src/META.cpp:65:36:   recursively required from ‘const bool Conteins<boost::mpl::v_iter<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 1l>, boost::mpl::v_iter<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 9l>, char>::value’
../src/META.cpp:65:36:   required from ‘const bool Conteins<boost::mpl::v_iter<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 0l>, boost::mpl::v_iter<boost::mpl::vector<Test1, int, Test2, Test3, char, double, char, double, Test2>, 9l>, char>::value’
../src/META.cpp:142:38:   required from here
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/aux_/integral_wrapper.hpp:72:88: fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)
     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next;
                                                                                        ^
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/aux_/integral_wrapper.hpp:36:95: note: in definition of macro ‘AUX_WRAPPER_INST’
 #       define AUX_WRAPPER_INST(value) BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::AUX_WRAPPER_NAME< value >
                                                                                               ^
/home/diman-pro/workcpp/boost_1_64_0/boost/mpl/aux_/integral_wrapper.hpp:72:31: note: in expansion of macro ‘BOOST_MPL_AUX_STATIC_CAST’
     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next;
                               ^
compilation terminated.

告诉我,我做错了什么?

0 个答案:

没有答案