Title
Incorrect specification of "..._byname" facets
Status
cd1
Section
[locale.categories]
Submitter
Dietmar Kühl

Created on 2000-04-20.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

[ Copenhagen: proposed resolution was revised slightly, to remove three last virtual functions from messages_byname. ]

Date: 2010-10-21.18:28:33

[ Post-Tokyo: Dietmar Kühl submitted this issue at the request of the LWG to solve the underlying problems raised by issue 138. ]

Date: 2010-10-21.18:28:33

Proposed resolution:

  Change section 22.2.1.2 (lib.locale.ctype.byname) to become:

     namespace std {
       template <class charT>
       class ctype_byname : public ctype<charT> {
       public:
         typedef ctype<charT>::mask mask;
         explicit ctype_byname(const char*, size_t refs = 0);
       protected:
        ~ctype_byname();             //  virtual
       };
     }

  Change section 22.2.1.6 (lib.locale.codecvt.byname) to become:

    namespace std {
      template <class internT, class externT, class stateT>
      class codecvt_byname : public codecvt<internT, externT, stateT> {
      public:
       explicit codecvt_byname(const char*, size_t refs = 0);
      protected:
      ~codecvt_byname();             //  virtual
       };
     }

  Change section 22.2.3.2 (lib.locale.numpunct.byname) to become:

     namespace std {
       template <class charT>
       class numpunct_byname : public numpunct<charT> {
     //  this class is specialized for  char  and  wchar_t.
       public:
         typedef charT                char_type;
         typedef basic_string<charT>  string_type;
         explicit numpunct_byname(const char*, size_t refs = 0);
       protected:
        ~numpunct_byname();          //  virtual
       };
     }

  Change section 22.2.4.2 (lib.locale.collate.byname) to become:

     namespace std {
       template <class charT>
       class collate_byname : public collate<charT> {
       public:
         typedef basic_string<charT> string_type;
         explicit collate_byname(const char*, size_t refs = 0);
       protected:
        ~collate_byname();           //  virtual
       };
     }

  Change section 22.2.5.2 (lib.locale.time.get.byname) to become:

     namespace std {
       template <class charT, class InputIterator = istreambuf_iterator<charT> >
       class time_get_byname : public time_get<charT, InputIterator> {
       public:
         typedef time_base::dateorder dateorder;
         typedef InputIterator        iter_type
         explicit time_get_byname(const char*, size_t refs = 0);
       protected:
        ~time_get_byname();          //  virtual
       };
     }

  Change section 22.2.5.4 (lib.locale.time.put.byname) to become:

     namespace std {
       template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
       class time_put_byname : public time_put<charT, OutputIterator>
       {
       public:
         typedef charT          char_type;
         typedef OutputIterator iter_type;
         explicit time_put_byname(const char*, size_t refs = 0);
       protected:
        ~time_put_byname();          //  virtual
       };
     }"

  Change section 22.2.6.4 (lib.locale.moneypunct.byname) to become:

     namespace std {
       template <class charT, bool Intl = false>
       class moneypunct_byname : public moneypunct<charT, Intl> {
       public:
         typedef money_base::pattern pattern;
         typedef basic_string<charT> string_type;
         explicit moneypunct_byname(const char*, size_t refs = 0);
       protected:
        ~moneypunct_byname();        //  virtual
       };
     }

  Change section 22.2.7.2 (lib.locale.messages.byname) to become:

     namespace std {
       template <class charT>
       class messages_byname : public messages<charT> {
       public:
         typedef messages_base::catalog catalog;
         typedef basic_string<charT>    string_type;
         explicit messages_byname(const char*, size_t refs = 0);
       protected:
        ~messages_byname();          //  virtual
       };
     }

Remove section [locale.codecvt] completely (because in this case only those members are defined to be virtual which are defined to be virtual in 'ctype<cT>'.)

Date: 2018-08-10.14:42:51

The sections [locale.ctype.byname], [locale.codecvt.byname], [locale.numpunct.byname], [locale.collate.byname], [locale.time.put.byname], [locale.moneypunct.byname], and [locale.messages.byname] overspecify the definitions of the "..._byname" classes by listing a bunch of virtual functions. At the same time, no semantics of these functions are defined. Real implementations do not define these functions because the functional part of the facets is actually implemented in the corresponding base classes and the constructor of the "..._byname" version just provides suitable date used by these implementations. For example, the 'numpunct' methods just return values from a struct. The base class uses a statically initialized struct while the derived version reads the contents of this struct from a table. However, no virtual function is defined in 'numpunct_byname'.

For most classes this does not impose a problem but specifically for 'ctype' it does: The specialization for 'ctype_byname<char>' is required because otherwise the semantics would change due to the virtual functions defined in the general version for 'ctype_byname': In 'ctype<char>' the method 'do_is()' is not virtual but it is made virtual in both 'ctype<cT>' and 'ctype_byname<cT>'. Thus, a class derived from 'ctype_byname<char>' can tell whether this class is specialized or not under the current specification: Without the specialization, 'do_is()' is virtual while with specialization it is not virtual.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1928
2010-10-21 18:28:33adminsetmessages: + msg1927
2010-10-21 18:28:33adminsetmessages: + msg1926
2000-04-20 00:00:00admincreate