Created on 2000-02-29.00:00:00 last changed 171 months ago
Proposed resolution:
Replace the "Classifying Japanese characters" example in 22.2.8, paragraph 11 with the following:
#include <locale>
namespace My { using namespace std; class JCtype : public locale::facet { public: static locale::id id; // required for use as a new locale facet bool is_kanji (wchar_t c) const; JCtype() {} protected: ~JCtype() {} }; }
// file: filt.C #include <iostream> #include <locale> #include "jctype" // above std::locale::id My::JCtype::id; // the static JCtype member declared above.
int main() { using namespace std; typedef ctype<wchar_t> wctype; locale loc(locale(""), // the user's preferred locale... new My::JCtype); // and a new feature ... wchar_t c = use_facet<wctype>(loc).widen('!'); if (!use_facet<My::JCtype>(loc).is_kanji(c)) cout << "no it isn't!" << endl; return 0; }
The example in 22.2.8, paragraph 11 contains the following errors:
1) The member function `My::JCtype::is_kanji()' is non-const; the function must be const in order for it to be callable on a const object (a reference to which which is what std::use_facet<>() returns).
2) In file filt.C, the definition of `JCtype::id' must be qualified with the name of the namespace `My'.
3) In the definition of `loc' and subsequently in the call to use_facet<>() in main(), the name of the facet is misspelled: it should read `My::JCtype' rather than `My::JCType'.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg1885 |
2000-02-29 00:00:00 | admin | create |