This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: char_traits patch, round two


Benjamin Kosnik wrote:

Because of 21.1.1, p2? I always thought 21.1, p1 required the primary
template to be defined as well (not just declared). Seems like the
terminology used in the two paragraphs is kind of confused.

Perhaps. If you read 21.1.x closely, you'll see that


-2- The struct template

template<class charT> struct char_traits;

shall be provided in the header <string> as a basis for explicit specializations.

Right, but it doesn't say that it is just supposed to be declared
and not defined. It says that the template is supposed to be
*provided*.

You're probably right that it may not have been required to be
defined, likely because a number of its members cannot be defined
for any arbitrary POD type, but I don't think the language is there.

But given that programs are not allowed to specialize library
templates on native types, an implementation that doesn't provide
the primary template effectively prohibits programs from ever
using any specialization of, say, basic_string, on a native type
other than char or wchar_t.

I think the primary template should be explicitly required to
be defined, just like the codecvt primary template, for example,
is required to be defined, even if it may not make sense for any
arbitrary character type.

But as things stand right now, I agree that not providing the
primary template is not in conflict with the standard :)

Martin



and

namespace std {
template<> struct char_traits<char>;
template<> struct char_traits<wchar_t>;
}

-1- The header <string> declares two structs that are specializations of
the template struct char_traits.
Are the only explicitly specified bits in <string>

Please correct me if I've missed something. I believe the current 3.2
sources are standards-conforming.

For people who are curious, I suggest adding the generic defintions back
in and running the testsuite. The issues are immediately obvious.

-benjamin




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]