Topic: Defect Report: basic_istream::sentry::sentry() is uninstantiable with ctype<user-defined type>


Author: Matt McClure <matt.mcclure@ccur.com>
Date: 2000/01/19
Raw View
[ moderator's note: forwarded to C++ committee for handling -sdc ]

basic_istream::sentry::sentry() is uninstantiable with ctype<user-defined type>

Section: 27.6.1.1.2 lib.istream::sentry  Status: New  Submitter: Matt McClure and Dietmar Kuehl  Date: 1 Jan 2000

   Paragraph 4 states:

      To decide if the character c is a whitespace character, the constructor
      performs ''as if'' it executes the following code fragment:

         const ctype<charT>& ctype = use_facet<ctype<charT> >(is.getloc());
         if (ctype.is(ctype.space,c)!=0)
            // c is a whitespace character.

   But Table 51 in 22.1.1.1.1 only requires an implementation to provide
   specializations for ctype<char> and ctype<wchar_t>.  If sentry's constructor
   is implemented using ctype, it will be uninstantiable for a user-defined
   character type charT, unless the implementation has provided non-working
   (since it would be impossible to define a correct ctype<charT>
   specialization for an arbitrary charT) definitions of ctype's virtual member
   functions.

   It seems the intent the standard is that sentry should behave, in every
   respect, not just during execution, as if it were implemented using ctype,
   with the burden of providing a ctype specialization falling on the user.
   But as it is written, nothing requires the translation of sentry's
   constructor to behave as if it used the above code, and it would seem
   therefore, that sentry's constructor should be instantiable for all
   character types.

Proposed Resolution:

   Change paragraph 4 above to

      To decide if the character c is a whitespace character, the constructor
      behaves, during translation and execution ''as if'' it were implemented
      with the following code fragment: ...

   Note: If I have misinterpreted the intent of the standard with respect to
   sentry's constructor's instantiability, then a note should be added to the
   following effect:

      An implementation is forbidden from using the above code if it renders
      the constructor uninstantiable for an otherwise valid character type.

   In any event, some clarification is needed.

--
Matt McClure
Concurrent Computer Corporation


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]