Opened 12 years ago

Last modified 12 years ago

#4790 new Tasks

Suggest improvement to mpl::string documentation

Reported by: Joshua Hale <jgh.emc@…> Owned by: Aleksey Gurtovoy
Milestone: To Be Determined Component: mpl
Version: Boost 1.40.0 Severity: Cosmetic
Keywords: string Cc:

Description

I suggest adding a warning to the documentation for mpl::string regarding multi-byte character types.

Specifically, I was unable to compile the example:

typedef mpl::string<'hell','o wo','rld'> hello; typedef mpl::push_back<hello, mpl::char_<'!'> >::type hello2; BOOST_ASSERT(0 == std::strcmp(mpl::c_str<hello2>::value, "hello world!"));

Using g++ 4.4.3 I got:

error: multi-character character constant

Comprehending the problem involved investigating/learning the following points:

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

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).

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', ...).

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.

-Wno-multichar

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.

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.

Change History (1)

comment:1 by Joshua Hale <jgh.emc@…>, 12 years ago

I suggest adding a warning to the documentation for mpl::string regarding multi-byte character types.

Specifically, I was unable to compile the example:

typedef mpl::string<'hell','o wo','rld'> hello;

typedef mpl::push_back<hello, mpl::char_<'!'> >::type hello2;

BOOST_ASSERT(0 == std::strcmp(mpl::c_str<hello2>::value, "hello world!"));

Using g++ 4.4.3 I got:

error: multi-character character constant

Comprehending the problem involved investigating/learning the following points:

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

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).

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', ...).

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.

-Wno-multichar

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.

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.

Note: See TracTickets for help on using tickets.