我想通过使用boost :: mpl :: fold来处理一些模板参数 . 目前,我仍然坚持Boost提供的样本,即使这对我不起作用 . 我收到以下错误:
..\src\main.cpp:18:32: error: template argument 2 is invalid
..\src\main.cpp:18:37: error: wrong number of template arguments (4, should be 3)
以下代码取自http://www.boost.org/doc/libs/1_48_0/libs/mpl/doc/refmanual/fold.html
#include <string>
#include <iostream>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits.hpp>
using namespace std;
using namespace boost;
using namespace boost::mpl;
using namespace boost::type_traits;
typedef vector<long,float,short,double,float,long,long double> types;
typedef fold<
types
, int_<0>
, if_< is_float<_2>,next<_1>,_1 >
>::type number_of_floats;
BOOST_MPL_ASSERT_RELATION( number_of_floats::value, ==, 4 );
int main(){
}
我正在使用标志“-std = c 11”运行mingw 4.7.0 . 我在网上找到了一些其他的例子,但还没有成功编译任何有用的东西 . 有什么建议?
1 回答
你搞乱了命名空间 . 使很多符号模糊不清 .
删除
using
,该示例适合我 .