【发布时间】:2016-06-03 06:05:00
【问题描述】:
这是我正在处理的用例的较小版本。
#ifndef BOOST_MPL_LIMIT_STRING_SIZE
# define BOOST_MPL_LIMIT_STRING_SIZE 64
#endif
#include <boost/mpl/string.hpp>
#include <iostream>
using str = boost::mpl::string<'a','b','c','d','e','f','.','g','h','i','j','k','l','m','n','.','o','p','q','r','s','t','u','v','w','x','y','z'>;
int main()
{
std::cout<<"String is "<<boost::mpl::c_str<str>::value<<std::endl;
}
使用 gcc 4.9.3 给了我以下错误消息。
source2.cpp:19:143: error: wrong number of template arguments (28, should be 16)
using str = boost::mpl::string<'a','b','c','d','e','f','.','g','h','i','j','k','l','m','n','.','o','p','q','r','s','t','u','v','w','x','y','z'>;
^
In file included from source2.cpp:16:0:
/boost/include/boost/mpl/string.hpp:135:12: error: provided for ‘template<int C0, int C1, int C2, int C3, int C4, int C5, int C6, int C7, int C8, int C9, int C10, int C11, int C12, int C13, int C14, int C15> struct boost::mpl::string’
struct string;
^
source2.cpp: In function ‘int main()’:
source2.cpp:23:48: error: ‘str’ was not declared in this scope
std::cout<<"String is "<<boost::mpl::c_str<str>::value<<std::endl;
^
source2.cpp:23:51: error: template argument 1 is invalid
std::cout<<"String is "<<boost::mpl::c_str<str>::value<<std::endl;
我已经咨询了一堆与boost::mpl::string 相关的问题,但并没有解决我的问题。
为什么即使我已经覆盖了大小,编译器也会给我错误消息?
我是否遗漏了一些非常明显的东西?
【问题讨论】: