Boost C++ Libraries: Ticket #4790: Suggest improvement to mpl::string documentation https://svn.boost.org/trac10/ticket/4790 <p> I suggest adding a warning to the documentation for mpl::string regarding multi-byte character types. </p> <p> Specifically, I was unable to compile the example: </p> <blockquote> <p> typedef mpl::string&lt;'hell','o wo','rld'&gt; hello; typedef mpl::push_back&lt;hello, mpl::char_&lt;'!'&gt; &gt;::type hello2; BOOST_ASSERT(0 == std::strcmp(mpl::c_str&lt;hello2&gt;::value, "hello world!")); </p> </blockquote> <p> Using g++ 4.4.3 I got: </p> <blockquote> <p> error: multi-character character constant </p> </blockquote> <p> Comprehending the problem involved investigating/learning the following points: </p> <blockquote> <p> what is a multi-character literal the warning in g++ can be disabled with -Wno-multichar (I always use -Werror, hence all warnings generate errors) the maximum length of a multi-character literal on my system is 4 characters </p> </blockquote> <p> The latter two points are OS specific and therefore don't seem appropriate for the mpl::string documentation, and the first point may I guess be regarded as expected prior knowledge (though a one sentence summary would save a lot of time since they appear to be not so widely known). </p> <p> But I do recommend adding a caveat beside the example code regarding possible problems compiling multi-character literals, and the alternative equivalent example with the characters independently ('h','e','l', ...). </p> <p> I also recommend including a warning regarding their implementation-dependent nature (based on what the g++ manual has to say; copied below) since they appear likely to propagate portability problems. </p> <p> -Wno-multichar </p> <blockquote> <p> Do not warn if a multicharacter constant ('FOOF') is used. Usually they indicate a typo in the user's code, as they have implementation-defined values, and should not be used in portable code. </p> </blockquote> <p> I hope this comment is useful. I am repeatedly awed by the cunning majesty of all the boost libraries I have explored and the MPL may be, for me, at the peak in that respect. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4790 Trac 1.4.3 Joshua Hale <jgh.emc@…> Tue, 26 Oct 2010 03:34:05 GMT <link>https://svn.boost.org/trac10/ticket/4790#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4790#comment:1</guid> <description> <p> I suggest adding a warning to the documentation for mpl::string regarding multi-byte character types. </p> <p> Specifically, I was unable to compile the example: </p> <blockquote> <p> typedef mpl::string&lt;'hell','o wo','rld'&gt; hello; </p> </blockquote> <blockquote> <p> typedef mpl::push_back&lt;hello, mpl::char_&lt;'!'&gt; &gt;::type hello2; </p> </blockquote> <blockquote> <p> BOOST_ASSERT(0 == std::strcmp(mpl::c_str&lt;hello2&gt;::value, "hello world!")); </p> </blockquote> <p> Using g++ 4.4.3 I got: </p> <blockquote> <p> error: multi-character character constant </p> </blockquote> <p> Comprehending the problem involved investigating/learning the following points: </p> <blockquote> <p> what is a multi-character literal </p> </blockquote> <blockquote> <p> the warning in g++ can be disabled with -Wno-multichar </p> <blockquote> <p> (I always use -Werror, hence all warnings generate errors) </p> </blockquote> </blockquote> <blockquote> <p> the maximum length of a multi-character literal on my system is 4 characters </p> </blockquote> <p> The latter two points are OS specific and therefore don't seem appropriate for the mpl::string documentation, and the first point may I guess be regarded as expected prior knowledge (though a one sentence summary would save a lot of time since they appear to be not so widely known). </p> <p> But I do recommend adding a caveat beside the example code regarding possible problems compiling multi-character literals, and the alternative equivalent example with the characters independently ('h','e','l', ...). </p> <p> I also recommend including a warning regarding their implementation-dependent nature (based on what the g++ manual has to say; copied below) since they appear likely to propagate portability problems. </p> <blockquote> <p> -Wno-multichar </p> </blockquote> <blockquote> <blockquote> <p> Do not warn if a multicharacter constant ('FOOF') is used. Usually they indicate a typo in the user's code, as they have implementation-defined values, and should not be used in portable code. </p> </blockquote> </blockquote> <p> I hope this comment is useful. I am repeatedly awed by the cunning majesty of all the boost libraries I have explored and the MPL may be, for me, at the peak in that respect. </p> </description> <category>Ticket</category> </item> </channel> </rss>