
Hello,
the code here doesn't compile:
#include
#include <iostream> namespace mpl = boost::mpl;
typedef mpl::string<'h','e','l','l','o',' ','w','o','r','l','d'>::type my_hello;
int main() { std::cout << mpl::c_str
::value << '\n'; std::cout << BOOST_MPL_LIMIT_STRING_SIZE << '\n'; } As usual, the example from docs works. The error is:
$ LANG=en g++ t.cpp -o t && ./t t.cpp:6:64: error: wrong number of template arguments (11, should be 8) /usr/local/include/boost/mpl/string.hpp:102:12: error: provided for 'template
struct boost::mpl::string' t.cpp:6:72: error: expected initializer before 'my_hello' t.cpp: In function 'int main()': t.cpp:10:26: error: 'my_hello' was not declared in this scope t.cpp:10:34: error: template argument 1 is invalid why does it complain about wrong number of template arguments? BOOST_MPL_LIMIT_STRING_SIZE is 32?
$ svn info ... Path: . URL: http://svn.boost.org/svn/boost/trunk Repository Root: http://svn.boost.org/svn/boost Repository UUID: b8fc166d-592f-0410-95f2-cb63ce0dd405 Revision: 83988 ... $ LANG=en g++ --version g++ (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2) ...
Thanks, Olaf
I'm surprised multi-character character constants are being used at all in Boost, they are not supposed to be portable: http://stackoverflow.com/questions/6944730/multiple-characters-in-a-characte... If you only want to use single character constants, you could place the following #define before any includes: #define BOOST_MPL_LIMIT_STRING_SIZE (32*4) That would allow up to 32, provided your compiler supports it (yet another portability issue). Since in C++, the type of 'x' is char, it should be possible to create another overload of mpl::string<> that takes BOOST_MPL_LIMIT_STRING_SIZE 'char's, which would work the way most people would expect. Dan Searles