/contrib/libstdc++/include/bits/locale_facets.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 4688 lines · 1690 code · 458 blank · 2540 comment · 53 complexity · 28a678fe0b8b6a609d3302064e0488ac MD5 · raw file

Large files are truncated click here to view the full file

  1. // Locale support -*- C++ -*-
  2. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
  3. // Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library. This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 2, or (at your option)
  9. // any later version.
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. // You should have received a copy of the GNU General Public License along
  15. // with this library; see the file COPYING. If not, write to the Free
  16. // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  17. // USA.
  18. // As a special exception, you may use this file as part of a free software
  19. // library without restriction. Specifically, if other files instantiate
  20. // templates or use macros or inline functions from this file, or you compile
  21. // this file and link it with other files to produce an executable, this
  22. // file does not by itself cause the resulting executable to be covered by
  23. // the GNU General Public License. This exception does not however
  24. // invalidate any other reasons why the executable file might be covered by
  25. // the GNU General Public License.
  26. /** @file locale_facets.h
  27. * This is an internal header file, included by other library headers.
  28. * You should not attempt to use it directly.
  29. */
  30. //
  31. // ISO C++ 14882: 22.1 Locales
  32. //
  33. #ifndef _LOCALE_FACETS_H
  34. #define _LOCALE_FACETS_H 1
  35. #pragma GCC system_header
  36. #include <ctime> // For struct tm
  37. #include <cwctype> // For wctype_t
  38. #include <bits/ctype_base.h>
  39. #include <iosfwd>
  40. #include <bits/ios_base.h> // For ios_base, ios_base::iostate
  41. #include <streambuf>
  42. #include <bits/cpp_type_traits.h>
  43. _GLIBCXX_BEGIN_NAMESPACE(std)
  44. // NB: Don't instantiate required wchar_t facets if no wchar_t support.
  45. #ifdef _GLIBCXX_USE_WCHAR_T
  46. # define _GLIBCXX_NUM_FACETS 28
  47. #else
  48. # define _GLIBCXX_NUM_FACETS 14
  49. #endif
  50. // Convert string to numeric value of type _Tv and store results.
  51. // NB: This is specialized for all required types, there is no
  52. // generic definition.
  53. template<typename _Tv>
  54. void
  55. __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
  56. const __c_locale& __cloc);
  57. // Explicit specializations for required types.
  58. template<>
  59. void
  60. __convert_to_v(const char*, float&, ios_base::iostate&,
  61. const __c_locale&);
  62. template<>
  63. void
  64. __convert_to_v(const char*, double&, ios_base::iostate&,
  65. const __c_locale&);
  66. template<>
  67. void
  68. __convert_to_v(const char*, long double&, ios_base::iostate&,
  69. const __c_locale&);
  70. // NB: __pad is a struct, rather than a function, so it can be
  71. // partially-specialized.
  72. template<typename _CharT, typename _Traits>
  73. struct __pad
  74. {
  75. static void
  76. _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
  77. const _CharT* __olds, const streamsize __newlen,
  78. const streamsize __oldlen, const bool __num);
  79. };
  80. // Used by both numeric and monetary facets.
  81. // Inserts "group separator" characters into an array of characters.
  82. // It's recursive, one iteration per group. It moves the characters
  83. // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
  84. // only with __glen != 0.
  85. template<typename _CharT>
  86. _CharT*
  87. __add_grouping(_CharT* __s, _CharT __sep,
  88. const char* __gbeg, size_t __gsize,
  89. const _CharT* __first, const _CharT* __last);
  90. // This template permits specializing facet output code for
  91. // ostreambuf_iterator. For ostreambuf_iterator, sputn is
  92. // significantly more efficient than incrementing iterators.
  93. template<typename _CharT>
  94. inline
  95. ostreambuf_iterator<_CharT>
  96. __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
  97. {
  98. __s._M_put(__ws, __len);
  99. return __s;
  100. }
  101. // This is the unspecialized form of the template.
  102. template<typename _CharT, typename _OutIter>
  103. inline
  104. _OutIter
  105. __write(_OutIter __s, const _CharT* __ws, int __len)
  106. {
  107. for (int __j = 0; __j < __len; __j++, ++__s)
  108. *__s = __ws[__j];
  109. return __s;
  110. }
  111. // 22.2.1.1 Template class ctype
  112. // Include host and configuration specific ctype enums for ctype_base.
  113. // Common base for ctype<_CharT>.
  114. /**
  115. * @brief Common base for ctype facet
  116. *
  117. * This template class provides implementations of the public functions
  118. * that forward to the protected virtual functions.
  119. *
  120. * This template also provides abtract stubs for the protected virtual
  121. * functions.
  122. */
  123. template<typename _CharT>
  124. class __ctype_abstract_base : public locale::facet, public ctype_base
  125. {
  126. public:
  127. // Types:
  128. /// Typedef for the template parameter
  129. typedef _CharT char_type;
  130. /**
  131. * @brief Test char_type classification.
  132. *
  133. * This function finds a mask M for @a c and compares it to mask @a m.
  134. * It does so by returning the value of ctype<char_type>::do_is().
  135. *
  136. * @param c The char_type to compare the mask of.
  137. * @param m The mask to compare against.
  138. * @return (M & m) != 0.
  139. */
  140. bool
  141. is(mask __m, char_type __c) const
  142. { return this->do_is(__m, __c); }
  143. /**
  144. * @brief Return a mask array.
  145. *
  146. * This function finds the mask for each char_type in the range [lo,hi)
  147. * and successively writes it to vec. vec must have as many elements
  148. * as the char array. It does so by returning the value of
  149. * ctype<char_type>::do_is().
  150. *
  151. * @param lo Pointer to start of range.
  152. * @param hi Pointer to end of range.
  153. * @param vec Pointer to an array of mask storage.
  154. * @return @a hi.
  155. */
  156. const char_type*
  157. is(const char_type *__lo, const char_type *__hi, mask *__vec) const
  158. { return this->do_is(__lo, __hi, __vec); }
  159. /**
  160. * @brief Find char_type matching a mask
  161. *
  162. * This function searches for and returns the first char_type c in
  163. * [lo,hi) for which is(m,c) is true. It does so by returning
  164. * ctype<char_type>::do_scan_is().
  165. *
  166. * @param m The mask to compare against.
  167. * @param lo Pointer to start of range.
  168. * @param hi Pointer to end of range.
  169. * @return Pointer to matching char_type if found, else @a hi.
  170. */
  171. const char_type*
  172. scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
  173. { return this->do_scan_is(__m, __lo, __hi); }
  174. /**
  175. * @brief Find char_type not matching a mask
  176. *
  177. * This function searches for and returns the first char_type c in
  178. * [lo,hi) for which is(m,c) is false. It does so by returning
  179. * ctype<char_type>::do_scan_not().
  180. *
  181. * @param m The mask to compare against.
  182. * @param lo Pointer to first char in range.
  183. * @param hi Pointer to end of range.
  184. * @return Pointer to non-matching char if found, else @a hi.
  185. */
  186. const char_type*
  187. scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
  188. { return this->do_scan_not(__m, __lo, __hi); }
  189. /**
  190. * @brief Convert to uppercase.
  191. *
  192. * This function converts the argument to uppercase if possible.
  193. * If not possible (for example, '2'), returns the argument. It does
  194. * so by returning ctype<char_type>::do_toupper().
  195. *
  196. * @param c The char_type to convert.
  197. * @return The uppercase char_type if convertible, else @a c.
  198. */
  199. char_type
  200. toupper(char_type __c) const
  201. { return this->do_toupper(__c); }
  202. /**
  203. * @brief Convert array to uppercase.
  204. *
  205. * This function converts each char_type in the range [lo,hi) to
  206. * uppercase if possible. Other elements remain untouched. It does so
  207. * by returning ctype<char_type>:: do_toupper(lo, hi).
  208. *
  209. * @param lo Pointer to start of range.
  210. * @param hi Pointer to end of range.
  211. * @return @a hi.
  212. */
  213. const char_type*
  214. toupper(char_type *__lo, const char_type* __hi) const
  215. { return this->do_toupper(__lo, __hi); }
  216. /**
  217. * @brief Convert to lowercase.
  218. *
  219. * This function converts the argument to lowercase if possible. If
  220. * not possible (for example, '2'), returns the argument. It does so
  221. * by returning ctype<char_type>::do_tolower(c).
  222. *
  223. * @param c The char_type to convert.
  224. * @return The lowercase char_type if convertible, else @a c.
  225. */
  226. char_type
  227. tolower(char_type __c) const
  228. { return this->do_tolower(__c); }
  229. /**
  230. * @brief Convert array to lowercase.
  231. *
  232. * This function converts each char_type in the range [lo,hi) to
  233. * lowercase if possible. Other elements remain untouched. It does so
  234. * by returning ctype<char_type>:: do_tolower(lo, hi).
  235. *
  236. * @param lo Pointer to start of range.
  237. * @param hi Pointer to end of range.
  238. * @return @a hi.
  239. */
  240. const char_type*
  241. tolower(char_type* __lo, const char_type* __hi) const
  242. { return this->do_tolower(__lo, __hi); }
  243. /**
  244. * @brief Widen char to char_type
  245. *
  246. * This function converts the char argument to char_type using the
  247. * simplest reasonable transformation. It does so by returning
  248. * ctype<char_type>::do_widen(c).
  249. *
  250. * Note: this is not what you want for codepage conversions. See
  251. * codecvt for that.
  252. *
  253. * @param c The char to convert.
  254. * @return The converted char_type.
  255. */
  256. char_type
  257. widen(char __c) const
  258. { return this->do_widen(__c); }
  259. /**
  260. * @brief Widen array to char_type
  261. *
  262. * This function converts each char in the input to char_type using the
  263. * simplest reasonable transformation. It does so by returning
  264. * ctype<char_type>::do_widen(c).
  265. *
  266. * Note: this is not what you want for codepage conversions. See
  267. * codecvt for that.
  268. *
  269. * @param lo Pointer to start of range.
  270. * @param hi Pointer to end of range.
  271. * @param to Pointer to the destination array.
  272. * @return @a hi.
  273. */
  274. const char*
  275. widen(const char* __lo, const char* __hi, char_type* __to) const
  276. { return this->do_widen(__lo, __hi, __to); }
  277. /**
  278. * @brief Narrow char_type to char
  279. *
  280. * This function converts the char_type to char using the simplest
  281. * reasonable transformation. If the conversion fails, dfault is
  282. * returned instead. It does so by returning
  283. * ctype<char_type>::do_narrow(c).
  284. *
  285. * Note: this is not what you want for codepage conversions. See
  286. * codecvt for that.
  287. *
  288. * @param c The char_type to convert.
  289. * @param dfault Char to return if conversion fails.
  290. * @return The converted char.
  291. */
  292. char
  293. narrow(char_type __c, char __dfault) const
  294. { return this->do_narrow(__c, __dfault); }
  295. /**
  296. * @brief Narrow array to char array
  297. *
  298. * This function converts each char_type in the input to char using the
  299. * simplest reasonable transformation and writes the results to the
  300. * destination array. For any char_type in the input that cannot be
  301. * converted, @a dfault is used instead. It does so by returning
  302. * ctype<char_type>::do_narrow(lo, hi, dfault, to).
  303. *
  304. * Note: this is not what you want for codepage conversions. See
  305. * codecvt for that.
  306. *
  307. * @param lo Pointer to start of range.
  308. * @param hi Pointer to end of range.
  309. * @param dfault Char to use if conversion fails.
  310. * @param to Pointer to the destination array.
  311. * @return @a hi.
  312. */
  313. const char_type*
  314. narrow(const char_type* __lo, const char_type* __hi,
  315. char __dfault, char *__to) const
  316. { return this->do_narrow(__lo, __hi, __dfault, __to); }
  317. protected:
  318. explicit
  319. __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
  320. virtual
  321. ~__ctype_abstract_base() { }
  322. /**
  323. * @brief Test char_type classification.
  324. *
  325. * This function finds a mask M for @a c and compares it to mask @a m.
  326. *
  327. * do_is() is a hook for a derived facet to change the behavior of
  328. * classifying. do_is() must always return the same result for the
  329. * same input.
  330. *
  331. * @param c The char_type to find the mask of.
  332. * @param m The mask to compare against.
  333. * @return (M & m) != 0.
  334. */
  335. virtual bool
  336. do_is(mask __m, char_type __c) const = 0;
  337. /**
  338. * @brief Return a mask array.
  339. *
  340. * This function finds the mask for each char_type in the range [lo,hi)
  341. * and successively writes it to vec. vec must have as many elements
  342. * as the input.
  343. *
  344. * do_is() is a hook for a derived facet to change the behavior of
  345. * classifying. do_is() must always return the same result for the
  346. * same input.
  347. *
  348. * @param lo Pointer to start of range.
  349. * @param hi Pointer to end of range.
  350. * @param vec Pointer to an array of mask storage.
  351. * @return @a hi.
  352. */
  353. virtual const char_type*
  354. do_is(const char_type* __lo, const char_type* __hi,
  355. mask* __vec) const = 0;
  356. /**
  357. * @brief Find char_type matching mask
  358. *
  359. * This function searches for and returns the first char_type c in
  360. * [lo,hi) for which is(m,c) is true.
  361. *
  362. * do_scan_is() is a hook for a derived facet to change the behavior of
  363. * match searching. do_is() must always return the same result for the
  364. * same input.
  365. *
  366. * @param m The mask to compare against.
  367. * @param lo Pointer to start of range.
  368. * @param hi Pointer to end of range.
  369. * @return Pointer to a matching char_type if found, else @a hi.
  370. */
  371. virtual const char_type*
  372. do_scan_is(mask __m, const char_type* __lo,
  373. const char_type* __hi) const = 0;
  374. /**
  375. * @brief Find char_type not matching mask
  376. *
  377. * This function searches for and returns a pointer to the first
  378. * char_type c of [lo,hi) for which is(m,c) is false.
  379. *
  380. * do_scan_is() is a hook for a derived facet to change the behavior of
  381. * match searching. do_is() must always return the same result for the
  382. * same input.
  383. *
  384. * @param m The mask to compare against.
  385. * @param lo Pointer to start of range.
  386. * @param hi Pointer to end of range.
  387. * @return Pointer to a non-matching char_type if found, else @a hi.
  388. */
  389. virtual const char_type*
  390. do_scan_not(mask __m, const char_type* __lo,
  391. const char_type* __hi) const = 0;
  392. /**
  393. * @brief Convert to uppercase.
  394. *
  395. * This virtual function converts the char_type argument to uppercase
  396. * if possible. If not possible (for example, '2'), returns the
  397. * argument.
  398. *
  399. * do_toupper() is a hook for a derived facet to change the behavior of
  400. * uppercasing. do_toupper() must always return the same result for
  401. * the same input.
  402. *
  403. * @param c The char_type to convert.
  404. * @return The uppercase char_type if convertible, else @a c.
  405. */
  406. virtual char_type
  407. do_toupper(char_type) const = 0;
  408. /**
  409. * @brief Convert array to uppercase.
  410. *
  411. * This virtual function converts each char_type in the range [lo,hi)
  412. * to uppercase if possible. Other elements remain untouched.
  413. *
  414. * do_toupper() is a hook for a derived facet to change the behavior of
  415. * uppercasing. do_toupper() must always return the same result for
  416. * the same input.
  417. *
  418. * @param lo Pointer to start of range.
  419. * @param hi Pointer to end of range.
  420. * @return @a hi.
  421. */
  422. virtual const char_type*
  423. do_toupper(char_type* __lo, const char_type* __hi) const = 0;
  424. /**
  425. * @brief Convert to lowercase.
  426. *
  427. * This virtual function converts the argument to lowercase if
  428. * possible. If not possible (for example, '2'), returns the argument.
  429. *
  430. * do_tolower() is a hook for a derived facet to change the behavior of
  431. * lowercasing. do_tolower() must always return the same result for
  432. * the same input.
  433. *
  434. * @param c The char_type to convert.
  435. * @return The lowercase char_type if convertible, else @a c.
  436. */
  437. virtual char_type
  438. do_tolower(char_type) const = 0;
  439. /**
  440. * @brief Convert array to lowercase.
  441. *
  442. * This virtual function converts each char_type in the range [lo,hi)
  443. * to lowercase if possible. Other elements remain untouched.
  444. *
  445. * do_tolower() is a hook for a derived facet to change the behavior of
  446. * lowercasing. do_tolower() must always return the same result for
  447. * the same input.
  448. *
  449. * @param lo Pointer to start of range.
  450. * @param hi Pointer to end of range.
  451. * @return @a hi.
  452. */
  453. virtual const char_type*
  454. do_tolower(char_type* __lo, const char_type* __hi) const = 0;
  455. /**
  456. * @brief Widen char
  457. *
  458. * This virtual function converts the char to char_type using the
  459. * simplest reasonable transformation.
  460. *
  461. * do_widen() is a hook for a derived facet to change the behavior of
  462. * widening. do_widen() must always return the same result for the
  463. * same input.
  464. *
  465. * Note: this is not what you want for codepage conversions. See
  466. * codecvt for that.
  467. *
  468. * @param c The char to convert.
  469. * @return The converted char_type
  470. */
  471. virtual char_type
  472. do_widen(char) const = 0;
  473. /**
  474. * @brief Widen char array
  475. *
  476. * This function converts each char in the input to char_type using the
  477. * simplest reasonable transformation.
  478. *
  479. * do_widen() is a hook for a derived facet to change the behavior of
  480. * widening. do_widen() must always return the same result for the
  481. * same input.
  482. *
  483. * Note: this is not what you want for codepage conversions. See
  484. * codecvt for that.
  485. *
  486. * @param lo Pointer to start range.
  487. * @param hi Pointer to end of range.
  488. * @param to Pointer to the destination array.
  489. * @return @a hi.
  490. */
  491. virtual const char*
  492. do_widen(const char* __lo, const char* __hi,
  493. char_type* __dest) const = 0;
  494. /**
  495. * @brief Narrow char_type to char
  496. *
  497. * This virtual function converts the argument to char using the
  498. * simplest reasonable transformation. If the conversion fails, dfault
  499. * is returned instead.
  500. *
  501. * do_narrow() is a hook for a derived facet to change the behavior of
  502. * narrowing. do_narrow() must always return the same result for the
  503. * same input.
  504. *
  505. * Note: this is not what you want for codepage conversions. See
  506. * codecvt for that.
  507. *
  508. * @param c The char_type to convert.
  509. * @param dfault Char to return if conversion fails.
  510. * @return The converted char.
  511. */
  512. virtual char
  513. do_narrow(char_type, char __dfault) const = 0;
  514. /**
  515. * @brief Narrow char_type array to char
  516. *
  517. * This virtual function converts each char_type in the range [lo,hi) to
  518. * char using the simplest reasonable transformation and writes the
  519. * results to the destination array. For any element in the input that
  520. * cannot be converted, @a dfault is used instead.
  521. *
  522. * do_narrow() is a hook for a derived facet to change the behavior of
  523. * narrowing. do_narrow() must always return the same result for the
  524. * same input.
  525. *
  526. * Note: this is not what you want for codepage conversions. See
  527. * codecvt for that.
  528. *
  529. * @param lo Pointer to start of range.
  530. * @param hi Pointer to end of range.
  531. * @param dfault Char to use if conversion fails.
  532. * @param to Pointer to the destination array.
  533. * @return @a hi.
  534. */
  535. virtual const char_type*
  536. do_narrow(const char_type* __lo, const char_type* __hi,
  537. char __dfault, char* __dest) const = 0;
  538. };
  539. // NB: Generic, mostly useless implementation.
  540. /**
  541. * @brief Template ctype facet
  542. *
  543. * This template class defines classification and conversion functions for
  544. * character sets. It wraps <cctype> functionality. Ctype gets used by
  545. * streams for many I/O operations.
  546. *
  547. * This template provides the protected virtual functions the developer
  548. * will have to replace in a derived class or specialization to make a
  549. * working facet. The public functions that access them are defined in
  550. * __ctype_abstract_base, to allow for implementation flexibility. See
  551. * ctype<wchar_t> for an example. The functions are documented in
  552. * __ctype_abstract_base.
  553. *
  554. * Note: implementations are provided for all the protected virtual
  555. * functions, but will likely not be useful.
  556. */
  557. template<typename _CharT>
  558. class ctype : public __ctype_abstract_base<_CharT>
  559. {
  560. public:
  561. // Types:
  562. typedef _CharT char_type;
  563. typedef typename __ctype_abstract_base<_CharT>::mask mask;
  564. /// The facet id for ctype<char_type>
  565. static locale::id id;
  566. explicit
  567. ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
  568. protected:
  569. virtual
  570. ~ctype();
  571. virtual bool
  572. do_is(mask __m, char_type __c) const;
  573. virtual const char_type*
  574. do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
  575. virtual const char_type*
  576. do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
  577. virtual const char_type*
  578. do_scan_not(mask __m, const char_type* __lo,
  579. const char_type* __hi) const;
  580. virtual char_type
  581. do_toupper(char_type __c) const;
  582. virtual const char_type*
  583. do_toupper(char_type* __lo, const char_type* __hi) const;
  584. virtual char_type
  585. do_tolower(char_type __c) const;
  586. virtual const char_type*
  587. do_tolower(char_type* __lo, const char_type* __hi) const;
  588. virtual char_type
  589. do_widen(char __c) const;
  590. virtual const char*
  591. do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
  592. virtual char
  593. do_narrow(char_type, char __dfault) const;
  594. virtual const char_type*
  595. do_narrow(const char_type* __lo, const char_type* __hi,
  596. char __dfault, char* __dest) const;
  597. };
  598. template<typename _CharT>
  599. locale::id ctype<_CharT>::id;
  600. // 22.2.1.3 ctype<char> specialization.
  601. /**
  602. * @brief The ctype<char> specialization.
  603. *
  604. * This class defines classification and conversion functions for
  605. * the char type. It gets used by char streams for many I/O
  606. * operations. The char specialization provides a number of
  607. * optimizations as well.
  608. */
  609. template<>
  610. class ctype<char> : public locale::facet, public ctype_base
  611. {
  612. public:
  613. // Types:
  614. /// Typedef for the template parameter char.
  615. typedef char char_type;
  616. protected:
  617. // Data Members:
  618. __c_locale _M_c_locale_ctype;
  619. bool _M_del;
  620. __to_type _M_toupper;
  621. __to_type _M_tolower;
  622. const mask* _M_table;
  623. mutable char _M_widen_ok;
  624. mutable char _M_widen[1 + static_cast<unsigned char>(-1)];
  625. mutable char _M_narrow[1 + static_cast<unsigned char>(-1)];
  626. mutable char _M_narrow_ok; // 0 uninitialized, 1 init,
  627. // 2 memcpy can't be used
  628. public:
  629. /// The facet id for ctype<char>
  630. static locale::id id;
  631. /// The size of the mask table. It is SCHAR_MAX + 1.
  632. static const size_t table_size = 1 + static_cast<unsigned char>(-1);
  633. /**
  634. * @brief Constructor performs initialization.
  635. *
  636. * This is the constructor provided by the standard.
  637. *
  638. * @param table If non-zero, table is used as the per-char mask.
  639. * Else classic_table() is used.
  640. * @param del If true, passes ownership of table to this facet.
  641. * @param refs Passed to the base facet class.
  642. */
  643. explicit
  644. ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
  645. /**
  646. * @brief Constructor performs static initialization.
  647. *
  648. * This constructor is used to construct the initial C locale facet.
  649. *
  650. * @param cloc Handle to C locale data.
  651. * @param table If non-zero, table is used as the per-char mask.
  652. * @param del If true, passes ownership of table to this facet.
  653. * @param refs Passed to the base facet class.
  654. */
  655. explicit
  656. ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
  657. size_t __refs = 0);
  658. /**
  659. * @brief Test char classification.
  660. *
  661. * This function compares the mask table[c] to @a m.
  662. *
  663. * @param c The char to compare the mask of.
  664. * @param m The mask to compare against.
  665. * @return True if m & table[c] is true, false otherwise.
  666. */
  667. inline bool
  668. is(mask __m, char __c) const;
  669. /**
  670. * @brief Return a mask array.
  671. *
  672. * This function finds the mask for each char in the range [lo, hi) and
  673. * successively writes it to vec. vec must have as many elements as
  674. * the char array.
  675. *
  676. * @param lo Pointer to start of range.
  677. * @param hi Pointer to end of range.
  678. * @param vec Pointer to an array of mask storage.
  679. * @return @a hi.
  680. */
  681. inline const char*
  682. is(const char* __lo, const char* __hi, mask* __vec) const;
  683. /**
  684. * @brief Find char matching a mask
  685. *
  686. * This function searches for and returns the first char in [lo,hi) for
  687. * which is(m,char) is true.
  688. *
  689. * @param m The mask to compare against.
  690. * @param lo Pointer to start of range.
  691. * @param hi Pointer to end of range.
  692. * @return Pointer to a matching char if found, else @a hi.
  693. */
  694. inline const char*
  695. scan_is(mask __m, const char* __lo, const char* __hi) const;
  696. /**
  697. * @brief Find char not matching a mask
  698. *
  699. * This function searches for and returns a pointer to the first char
  700. * in [lo,hi) for which is(m,char) is false.
  701. *
  702. * @param m The mask to compare against.
  703. * @param lo Pointer to start of range.
  704. * @param hi Pointer to end of range.
  705. * @return Pointer to a non-matching char if found, else @a hi.
  706. */
  707. inline const char*
  708. scan_not(mask __m, const char* __lo, const char* __hi) const;
  709. /**
  710. * @brief Convert to uppercase.
  711. *
  712. * This function converts the char argument to uppercase if possible.
  713. * If not possible (for example, '2'), returns the argument.
  714. *
  715. * toupper() acts as if it returns ctype<char>::do_toupper(c).
  716. * do_toupper() must always return the same result for the same input.
  717. *
  718. * @param c The char to convert.
  719. * @return The uppercase char if convertible, else @a c.
  720. */
  721. char_type
  722. toupper(char_type __c) const
  723. { return this->do_toupper(__c); }
  724. /**
  725. * @brief Convert array to uppercase.
  726. *
  727. * This function converts each char in the range [lo,hi) to uppercase
  728. * if possible. Other chars remain untouched.
  729. *
  730. * toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
  731. * do_toupper() must always return the same result for the same input.
  732. *
  733. * @param lo Pointer to first char in range.
  734. * @param hi Pointer to end of range.
  735. * @return @a hi.
  736. */
  737. const char_type*
  738. toupper(char_type *__lo, const char_type* __hi) const
  739. { return this->do_toupper(__lo, __hi); }
  740. /**
  741. * @brief Convert to lowercase.
  742. *
  743. * This function converts the char argument to lowercase if possible.
  744. * If not possible (for example, '2'), returns the argument.
  745. *
  746. * tolower() acts as if it returns ctype<char>::do_tolower(c).
  747. * do_tolower() must always return the same result for the same input.
  748. *
  749. * @param c The char to convert.
  750. * @return The lowercase char if convertible, else @a c.
  751. */
  752. char_type
  753. tolower(char_type __c) const
  754. { return this->do_tolower(__c); }
  755. /**
  756. * @brief Convert array to lowercase.
  757. *
  758. * This function converts each char in the range [lo,hi) to lowercase
  759. * if possible. Other chars remain untouched.
  760. *
  761. * tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
  762. * do_tolower() must always return the same result for the same input.
  763. *
  764. * @param lo Pointer to first char in range.
  765. * @param hi Pointer to end of range.
  766. * @return @a hi.
  767. */
  768. const char_type*
  769. tolower(char_type* __lo, const char_type* __hi) const
  770. { return this->do_tolower(__lo, __hi); }
  771. /**
  772. * @brief Widen char
  773. *
  774. * This function converts the char to char_type using the simplest
  775. * reasonable transformation. For an underived ctype<char> facet, the
  776. * argument will be returned unchanged.
  777. *
  778. * This function works as if it returns ctype<char>::do_widen(c).
  779. * do_widen() must always return the same result for the same input.
  780. *
  781. * Note: this is not what you want for codepage conversions. See
  782. * codecvt for that.
  783. *
  784. * @param c The char to convert.
  785. * @return The converted character.
  786. */
  787. char_type
  788. widen(char __c) const
  789. {
  790. if (_M_widen_ok)
  791. return _M_widen[static_cast<unsigned char>(__c)];
  792. this->_M_widen_init();
  793. return this->do_widen(__c);
  794. }
  795. /**
  796. * @brief Widen char array
  797. *
  798. * This function converts each char in the input to char using the
  799. * simplest reasonable transformation. For an underived ctype<char>
  800. * facet, the argument will be copied unchanged.
  801. *
  802. * This function works as if it returns ctype<char>::do_widen(c).
  803. * do_widen() must always return the same result for the same input.
  804. *
  805. * Note: this is not what you want for codepage conversions. See
  806. * codecvt for that.
  807. *
  808. * @param lo Pointer to first char in range.
  809. * @param hi Pointer to end of range.
  810. * @param to Pointer to the destination array.
  811. * @return @a hi.
  812. */
  813. const char*
  814. widen(const char* __lo, const char* __hi, char_type* __to) const
  815. {
  816. if (_M_widen_ok == 1)
  817. {
  818. memcpy(__to, __lo, __hi - __lo);
  819. return __hi;
  820. }
  821. if (!_M_widen_ok)
  822. _M_widen_init();
  823. return this->do_widen(__lo, __hi, __to);
  824. }
  825. /**
  826. * @brief Narrow char
  827. *
  828. * This function converts the char to char using the simplest
  829. * reasonable transformation. If the conversion fails, dfault is
  830. * returned instead. For an underived ctype<char> facet, @a c
  831. * will be returned unchanged.
  832. *
  833. * This function works as if it returns ctype<char>::do_narrow(c).
  834. * do_narrow() must always return the same result for the same input.
  835. *
  836. * Note: this is not what you want for codepage conversions. See
  837. * codecvt for that.
  838. *
  839. * @param c The char to convert.
  840. * @param dfault Char to return if conversion fails.
  841. * @return The converted character.
  842. */
  843. char
  844. narrow(char_type __c, char __dfault) const
  845. {
  846. if (_M_narrow[static_cast<unsigned char>(__c)])
  847. return _M_narrow[static_cast<unsigned char>(__c)];
  848. const char __t = do_narrow(__c, __dfault);
  849. if (__t != __dfault)
  850. _M_narrow[static_cast<unsigned char>(__c)] = __t;
  851. return __t;
  852. }
  853. /**
  854. * @brief Narrow char array
  855. *
  856. * This function converts each char in the input to char using the
  857. * simplest reasonable transformation and writes the results to the
  858. * destination array. For any char in the input that cannot be
  859. * converted, @a dfault is used instead. For an underived ctype<char>
  860. * facet, the argument will be copied unchanged.
  861. *
  862. * This function works as if it returns ctype<char>::do_narrow(lo, hi,
  863. * dfault, to). do_narrow() must always return the same result for the
  864. * same input.
  865. *
  866. * Note: this is not what you want for codepage conversions. See
  867. * codecvt for that.
  868. *
  869. * @param lo Pointer to start of range.
  870. * @param hi Pointer to end of range.
  871. * @param dfault Char to use if conversion fails.
  872. * @param to Pointer to the destination array.
  873. * @return @a hi.
  874. */
  875. const char_type*
  876. narrow(const char_type* __lo, const char_type* __hi,
  877. char __dfault, char *__to) const
  878. {
  879. if (__builtin_expect(_M_narrow_ok == 1, true))
  880. {
  881. memcpy(__to, __lo, __hi - __lo);
  882. return __hi;
  883. }
  884. if (!_M_narrow_ok)
  885. _M_narrow_init();
  886. return this->do_narrow(__lo, __hi, __dfault, __to);
  887. }
  888. protected:
  889. /// Returns a pointer to the mask table provided to the constructor, or
  890. /// the default from classic_table() if none was provided.
  891. const mask*
  892. table() const throw()
  893. { return _M_table; }
  894. /// Returns a pointer to the C locale mask table.
  895. static const mask*
  896. classic_table() throw();
  897. /**
  898. * @brief Destructor.
  899. *
  900. * This function deletes table() if @a del was true in the
  901. * constructor.
  902. */
  903. virtual
  904. ~ctype();
  905. /**
  906. * @brief Convert to uppercase.
  907. *
  908. * This virtual function converts the char argument to uppercase if
  909. * possible. If not possible (for example, '2'), returns the argument.
  910. *
  911. * do_toupper() is a hook for a derived facet to change the behavior of
  912. * uppercasing. do_toupper() must always return the same result for
  913. * the same input.
  914. *
  915. * @param c The char to convert.
  916. * @return The uppercase char if convertible, else @a c.
  917. */
  918. virtual char_type
  919. do_toupper(char_type) const;
  920. /**
  921. * @brief Convert array to uppercase.
  922. *
  923. * This virtual function converts each char in the range [lo,hi) to
  924. * uppercase if possible. Other chars remain untouched.
  925. *
  926. * do_toupper() is a hook for a derived facet to change the behavior of
  927. * uppercasing. do_toupper() must always return the same result for
  928. * the same input.
  929. *
  930. * @param lo Pointer to start of range.
  931. * @param hi Pointer to end of range.
  932. * @return @a hi.
  933. */
  934. virtual const char_type*
  935. do_toupper(char_type* __lo, const char_type* __hi) const;
  936. /**
  937. * @brief Convert to lowercase.
  938. *
  939. * This virtual function converts the char argument to lowercase if
  940. * possible. If not possible (for example, '2'), returns the argument.
  941. *
  942. * do_tolower() is a hook for a derived facet to change the behavior of
  943. * lowercasing. do_tolower() must always return the same result for
  944. * the same input.
  945. *
  946. * @param c The char to convert.
  947. * @return The lowercase char if convertible, else @a c.
  948. */
  949. virtual char_type
  950. do_tolower(char_type) const;
  951. /**
  952. * @brief Convert array to lowercase.
  953. *
  954. * This virtual function converts each char in the range [lo,hi) to
  955. * lowercase if possible. Other chars remain untouched.
  956. *
  957. * do_tolower() is a hook for a derived facet to change the behavior of
  958. * lowercasing. do_tolower() must always return the same result for
  959. * the same input.
  960. *
  961. * @param lo Pointer to first char in range.
  962. * @param hi Pointer to end of range.
  963. * @return @a hi.
  964. */
  965. virtual const char_type*
  966. do_tolower(char_type* __lo, const char_type* __hi) const;
  967. /**
  968. * @brief Widen char
  969. *
  970. * This virtual function converts the char to char using the simplest
  971. * reasonable transformation. For an underived ctype<char> facet, the
  972. * argument will be returned unchanged.
  973. *
  974. * do_widen() is a hook for a derived facet to change the behavior of
  975. * widening. do_widen() must always return the same result for the
  976. * same input.
  977. *
  978. * Note: this is not what you want for codepage conversions. See
  979. * codecvt for that.
  980. *
  981. * @param c The char to convert.
  982. * @return The converted character.
  983. */
  984. virtual char_type
  985. do_widen(char __c) const
  986. { return __c; }
  987. /**
  988. * @brief Widen char array
  989. *
  990. * This function converts each char in the range [lo,hi) to char using
  991. * the simplest reasonable transformation. For an underived
  992. * ctype<char> facet, the argument will be copied unchanged.
  993. *
  994. * do_widen() is a hook for a derived facet to change the behavior of
  995. * widening. do_widen() must always return the same result for the
  996. * same input.
  997. *
  998. * Note: this is not what you want for codepage conversions. See
  999. * codecvt for that.
  1000. *
  1001. * @param lo Pointer to start of range.
  1002. * @param hi Pointer to end of range.
  1003. * @param to Pointer to the destination array.
  1004. * @return @a hi.
  1005. */
  1006. virtual const char*
  1007. do_widen(const char* __lo, const char* __hi, char_type* __dest) const
  1008. {
  1009. memcpy(__dest, __lo, __hi - __lo);
  1010. return __hi;
  1011. }
  1012. /**
  1013. * @brief Narrow char
  1014. *
  1015. * This virtual function converts the char to char using the simplest
  1016. * reasonable transformation. If the conversion fails, dfault is
  1017. * returned instead. For an underived ctype<char> facet, @a c will be
  1018. * returned unchanged.
  1019. *
  1020. * do_narrow() is a hook for a derived facet to change the behavior of
  1021. * narrowing. do_narrow() must always return the same result for the
  1022. * same input.
  1023. *
  1024. * Note: this is not what you want for codepage conversions. See
  1025. * codecvt for that.
  1026. *
  1027. * @param c The char to convert.
  1028. * @param dfault Char to return if conversion fails.
  1029. * @return The converted char.
  1030. */
  1031. virtual char
  1032. do_narrow(char_type __c, char) const
  1033. { return __c; }
  1034. /**
  1035. * @brief Narrow char array to char array
  1036. *
  1037. * This virtual function converts each char in the range [lo,hi) to
  1038. * char using the simplest reasonable transformation and writes the
  1039. * results to the destination array. For any char in the input that
  1040. * cannot be converted, @a dfault is used instead. For an underived
  1041. * ctype<char> facet, the argument will be copied unchanged.
  1042. *
  1043. * do_narrow() is a hook for a derived facet to change the behavior of
  1044. * narrowing. do_narrow() must always return the same result for the
  1045. * same input.
  1046. *
  1047. * Note: this is not what you want for codepage conversions. See
  1048. * codecvt for that.
  1049. *
  1050. * @param lo Pointer to start of range.
  1051. * @param hi Pointer to end of range.
  1052. * @param dfault Char to use if conversion fails.
  1053. * @param to Pointer to the destination array.
  1054. * @return @a hi.
  1055. */
  1056. virtual const char_type*
  1057. do_narrow(const char_type* __lo, const char_type* __hi,
  1058. char, char* __dest) const
  1059. {
  1060. memcpy(__dest, __lo, __hi - __lo);
  1061. return __hi;
  1062. }
  1063. private:
  1064. void _M_widen_init() const
  1065. {
  1066. char __tmp[sizeof(_M_widen)];
  1067. for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
  1068. __tmp[__i] = __i;
  1069. do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
  1070. _M_widen_ok = 1;
  1071. // Set _M_widen_ok to 2 if memcpy can't be used.
  1072. if (memcmp(__tmp, _M_widen, sizeof(_M_widen)))
  1073. _M_widen_ok = 2;
  1074. }
  1075. // Fill in the narrowing cache and flag whether all values are
  1076. // valid or not. _M_narrow_ok is set to 2 if memcpy can't
  1077. // be used.
  1078. void _M_narrow_init() const
  1079. {
  1080. char __tmp[sizeof(_M_narrow)];
  1081. for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
  1082. __tmp[__i] = __i;
  1083. do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
  1084. _M_narrow_ok = 1;
  1085. if (memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
  1086. _M_narrow_ok = 2;
  1087. else
  1088. {
  1089. // Deal with the special case of zero: renarrow with a
  1090. // different default and compare.
  1091. char __c;
  1092. do_narrow(__tmp, __tmp + 1, 1, &__c);
  1093. if (__c == 1)
  1094. _M_narrow_ok = 2;
  1095. }
  1096. }
  1097. };
  1098. template<>
  1099. const ctype<char>&
  1100. use_facet<ctype<char> >(const locale& __loc);
  1101. #ifdef _GLIBCXX_USE_WCHAR_T
  1102. // 22.2.1.3 ctype<wchar_t> specialization
  1103. /**
  1104. * @brief The ctype<wchar_t> specialization.
  1105. *
  1106. * This class defines classification and conversion functions for the
  1107. * wchar_t type. It gets used by wchar_t streams for many I/O operations.
  1108. * The wchar_t specialization provides a number of optimizations as well.
  1109. *
  1110. * ctype<wchar_t> inherits its public methods from
  1111. * __ctype_abstract_base<wchar_t>.
  1112. */
  1113. template<>
  1114. class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
  1115. {
  1116. public:
  1117. // Types:
  1118. /// Typedef for the template parameter wchar_t.
  1119. typedef wchar_t char_type;
  1120. typedef wctype_t __wmask_type;
  1121. protected:
  1122. __c_locale _M_c_locale_ctype;
  1123. // Pre-computed narrowed and widened chars.
  1124. bool _M_narrow_ok;
  1125. char _M_narrow[128];
  1126. wint_t _M_widen[1 + static_cast<unsigned char>(-1)];
  1127. // Pre-computed elements for do_is.
  1128. mask _M_bit[16];
  1129. __wmask_type _M_wmask[16];
  1130. public:
  1131. // Data Members:
  1132. /// The facet id for ctype<wchar_t>
  1133. static locale::id id;
  1134. /**
  1135. * @brief Constructor performs initialization.
  1136. *
  1137. * This is the constructor provided by the standard.
  1138. *
  1139. * @param refs Passed to the base facet class.
  1140. */
  1141. explicit
  1142. ctype(size_t __refs = 0);
  1143. /**
  1144. * @brief Constructor performs static initialization.
  1145. *
  1146. * This constructor is used to construct the initial C locale facet.
  1147. *
  1148. * @param cloc Handle to C locale data.
  1149. * @param refs Passed to the base facet class.
  1150. */
  1151. explicit
  1152. ctype(__c_locale __cloc, size_t __refs = 0);
  1153. protected:
  1154. __wmask_type
  1155. _M_convert_to_wmask(const mask __m) const;
  1156. /// Destructor
  1157. virtual
  1158. ~ctype();
  1159. /**
  1160. * @brief Test wchar_t classification.
  1161. *
  1162. * This function finds a mask M for @a c and compares it to mask @a m.
  1163. *
  1164. * do_is() is a hook for a derived facet to change the behavior of
  1165. * classifying. do_is() must always return the same result for the
  1166. * same input.
  1167. *
  1168. * @param c The wchar_t to find the mask of.
  1169. * @param m The mask to compare against.
  1170. * @return (M & m) != 0.
  1171. */
  1172. virtual bool
  1173. do_is(mask __m, char_type __c) const;
  1174. /**
  1175. * @brief Return a mask array.
  1176. *
  1177. * This function finds the mask for each wchar_t in the range [lo,hi)
  1178. * and successively writes it to vec. vec must have as many elements
  1179. * as the input.
  1180. *
  1181. * do_is() is a hook for a derived facet to change the behavior of
  1182. * classifying. do_is() must always return the same result for the
  1183. * same input.
  1184. *
  1185. * @param lo Pointer to start of range.
  1186. * @param hi Pointer to end of range.
  1187. * @param vec Pointer to an array of mask storage.
  1188. * @return @a hi.
  1189. */
  1190. virtual const char_type*
  1191. do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
  1192. /**
  1193. * @brief Find wchar_t matching mask
  1194. *
  1195. * This function searches for and returns the first wchar_t c in
  1196. * [lo,hi) for which is(m,c) is true.
  1197. *
  1198. * do_scan_is() is a hook for a derived facet to change the behavior of
  1199. * match searching. do_is() must always return the same result for the
  1200. * same input.
  1201. *
  1202. * @param m The mask to compare against.
  1203. * @param lo Pointer to start of range.
  1204. * @param hi Pointer to end of range.
  1205. * @return Pointer to a matching wchar_t if found, else @a hi.
  1206. */
  1207. virtual const char_type*
  1208. do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
  1209. /**
  1210. * @brief Find wchar_t not matching mask
  1211. *
  1212. * This function searches for and returns a pointer to the first
  1213. * wchar_t c of [lo,hi) for which is(m,c) is false.
  1214. *
  1215. * do_scan_is() is a hook for a derived facet to change the behavior of
  1216. * match searching. do_is() must always return the same result for the
  1217. * same input.
  1218. *
  1219. * @param m The mask to compare against.
  1220. * @param lo Pointer to start of range.
  1221. * @param hi Pointer to end of range.
  1222. * @return Pointer to a non-matching wchar_t if found, else @a hi.
  1223. */
  1224. virtual const char_type*
  1225. do_scan_not(mask __m, const char_type* __lo,
  1226. const char_type* __hi) const;
  1227. /**
  1228. * @brief Convert to uppercase.
  1229. *
  1230. * This virtual function converts the wchar_t argument to uppercase if
  1231. * possible. If not possible (for example, '2'), returns the argument.
  1232. *
  1233. * do_toupper() is a hook for a derived facet to change the behavior of
  1234. * uppercasing. do_toupper() must always return the same result for
  1235. * the same input.
  1236. *
  1237. * @param c The wchar_t to convert.
  1238. * @return The uppercase wchar_t if convertible, else @a c.
  1239. */
  1240. virtual char_type
  1241. do_toupper(char_type) const;
  1242. /**
  1243. * @brief Convert array to uppercase.
  1244. *
  1245. * This virtual function converts each wchar_t in the range [lo,hi) to
  1246. * uppercase if possible. Other elements remain untouched.
  1247. *
  1248. * do_toupper() is a hook for a derived facet to change the behavior of
  1249. * uppercasing. do_toupper() must always return the same result for
  1250. * the same input.
  1251. *
  1252. * @param lo Pointer to start of range.
  1253. * @param hi Pointer to end of range.
  1254. * @return @a hi.
  1255. */
  1256. virtual const char_type*
  1257. do_toupper(char_type* __lo, const char_type* __hi) const;
  1258. /**
  1259. * @brief Convert to lowercase.
  1260. *
  1261. * This virtual function converts the argument to lowercase if
  1262. * possible. If not possible (for example, '2'), returns the argument.
  1263. *
  1264. * do_tolower() is a hook for a derived facet to change the behavior of
  1265. * lowercasing. do_tolower() must always return the same result for
  1266. * the same input.
  1267. *
  1268. * @param c The wchar_t to convert.
  1269. * @return The lowercase wchar_t if convertible, else @a c.
  1270. */
  1271. virtual char_type
  1272. do_tolower(char_type) const;
  1273. /**
  1274. * @brief Convert array to lowercase.
  1275. *
  1276. * This virtual function converts each wchar_t in the range [lo,hi) to
  1277. * lowercase if possible. Other elements remain untouched.
  1278. *
  1279. * do_tolower() is a hook for a derived facet to change the behavior of
  1280. * lowercasing. do_tolower() must always return the same result for
  1281. * the same input.
  1282. *
  1283. * @param lo Pointer to start of range.
  1284. * @param hi Pointer to end of range.
  1285. * @return @a hi.
  1286. */
  1287. virtual const char_type*
  1288. do_tolower(char_type* __lo, const char_type* __hi) const;
  1289. /**
  1290. * @brief Widen char to wchar_t
  1291. *
  1292. * This virtual function converts the char to wchar_t using the
  1293. * simplest reasonable transformation. For an underived ctype<wchar_t>
  1294. * facet, the argument will be cast to wchar_t.
  1295. *
  1296. * do_widen() is a hook for a derived facet to change the behavior of
  1297. * widening. do_widen() must always return the same result for the
  1298. * same input.
  1299. *
  1300. * Note: this is not what you want for codepage conversions. See
  1301. * codecvt for that.
  1302. *
  1303. * @param c The char to convert.
  1304. * @return The converted wchar_t.
  1305. */
  1306. virtual char_type
  1307. do_widen(char) const;
  1308. /**
  1309. * @brief Widen char array to wchar_t array
  1310. *
  1311. * This function converts each char in the input to wchar_t using the
  1312. * simplest reasonable transformation. For an underived ctype<wchar_t>
  1313. * facet, the argu…