boost::mpl::字符串大小错误消息
boost::mpl::string size error messages
这是我正在处理的用例的较小版本。
#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
有关的问题,但它并没有解决我的问题。
为什么编译器在我覆盖了大小的情况下也会给我错误消息?
我错过了一些很明显的东西吗?
您必须将其作为多字符常量传递,并且不能超过 4 个字节。
#include <boost/mpl/string.hpp>
#include <iostream>
using str1 = boost::mpl::string<'abcd','ef.g','hijk','lmn.','opqr','stuv','wxyz'>;
int main()
{
std::cout<<"String is "<<boost::mpl::c_str<str1>::value<<std::endl;
}
更新::使用宏BOOST_MPL_LIMIT_STRING_SIZE
时考虑长度为 4 的每个模板参数。因此,在您的情况下,预期的字符串大小为 number of template arguments * 4
。因此,128 应该是一个不错的值。
相关文章:
- C++错误消息*成员参考.**初学者*
- 如何通过参数抛出错误消息
- glad 导致 glfwSwapBuffers 返回错误消息
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- 如何接受 [ENTER] 键作为无效输入并发送错误消息
- 重新定义预定义的 errno 错误消息 (E2BIG)
- SDL 映像:无法打开映像,仅显示错误消息
- 错误消息:使用"string* +="后"no match for 'operator+='"
- 错误消息"expected expression"....有人知道它为什么这么说吗?
- 在 Eclipse: "error: no match for 'operator='" 中获取错误消息
- GCC 警告和 gcc 错误消息之间的区别
- 为 c++ cin 上的输入数无效生成错误消息
- 来自带有mbedtls TLS的Mongoose Web服务器的错误消息
- 如何使用realsense摄像头调试ROS错误消息
- C++ 概念 - 需要括号中的概念会导致 2 条冲突的错误消息
- 编译器收到错误消息(textc.exe已停止)
- 结构数组的构造函数错误,错误消息:没有构造函数实例与参数列表匹配
- 使用 c++/WinRT Direct3D UWP Game DR 模板 Direct X11 的错误消息
- max_element() 给出非常奇怪的错误消息
- 不断收到错误消息,并非所有控制路径都返回值