Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/c++/15/bits/codecvt.h
1 // Locale support (codecvt) -*- C++ -*- 2 3 // Copyright (C) 2000-2025 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 3, or (at your option) 9 // any later version. 10 11 // This library is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 16 // Under Section 7 of GPL version 3, you are granted additional 17 // permissions described in the GCC Runtime Library Exception, version 18 // 3.1, as published by the Free Software Foundation. 19 20 // You should have received a copy of the GNU General Public License and 21 // a copy of the GCC Runtime Library Exception along with this program; 22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23 // <http://www.gnu.org/licenses/>. 24 25 /** @file bits/codecvt.h 26 * This is an internal header file, included by other library headers. 27 * Do not attempt to use it directly. @headername{locale} 28 */ 29 30 // 31 // ISO C++ 14882: 22.2.1.5 Template class codecvt 32 // 33 34 // Written by Benjamin Kosnik <bkoz@redhat.com> 35 36 #ifndef _CODECVT_H 37 #define _CODECVT_H 1 38 39 #ifdef _GLIBCXX_SYSHDR 40 #pragma GCC system_header 41 #endif 42 43 #include <bits/c++config.h> 44 #include <bits/locale_classes.h> // locale::facet 45 46 #pragma GCC diagnostic push 47 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template 48 49 namespace std _GLIBCXX_VISIBILITY(default) 50 { 51 _GLIBCXX_BEGIN_NAMESPACE_VERSION 52 53 /// Empty base class for codecvt facet [22.2.1.5]. 54 class codecvt_base 55 { 56 public: 57 enum result 58 { 59 ok, 60 partial, 61 error, 62 noconv 63 }; 64 }; 65 66 /** 67 * @brief Common base for codecvt functions. 68 * 69 * This template class provides implementations of the public functions 70 * that forward to the protected virtual functions. 71 * 72 * This template also provides abstract stubs for the protected virtual 73 * functions. 74 */ 75 template<typename _InternT, typename _ExternT, typename _StateT> 76 class __codecvt_abstract_base 77 : public locale::facet, public codecvt_base 78 { 79 public: 80 // Types: 81 typedef codecvt_base::result result; 82 typedef _InternT intern_type; 83 typedef _ExternT extern_type; 84 typedef _StateT state_type; 85 86 // 22.2.1.5.1 codecvt members 87 /** 88 * @brief Convert from internal to external character set. 89 * 90 * Converts input string of intern_type to output string of 91 * extern_type. This is analogous to wcsrtombs. It does this by 92 * calling codecvt::do_out. 93 * 94 * The source and destination character sets are determined by the 95 * facet's locale, internal and external types. 96 * 97 * The characters in [from,from_end) are converted and written to 98 * [to,to_end). from_next and to_next are set to point to the 99 * character following the last successfully converted character, 100 * respectively. If the result needed no conversion, from_next and 101 * to_next are not affected. 102 * 103 * The @a state argument should be initialized if the input is at the 104 * beginning and carried from a previous call if continuing 105 * conversion. There are no guarantees about how @a state is used. 106 * 107 * The result returned is a member of codecvt_base::result. If 108 * all the input is converted, returns codecvt_base::ok. If no 109 * conversion is necessary, returns codecvt_base::noconv. If 110 * the input ends early or there is insufficient space in the 111 * output, returns codecvt_base::partial. Otherwise the 112 * conversion failed and codecvt_base::error is returned. 113 * 114 * @param __state Persistent conversion state data. 115 * @param __from Start of input. 116 * @param __from_end End of input. 117 * @param __from_next Returns start of unconverted data. 118 * @param __to Start of output buffer. 119 * @param __to_end End of output buffer. 120 * @param __to_next Returns start of unused output area. 121 * @return codecvt_base::result. 122 */ 123 result 124 out(state_type& __state, const intern_type* __from, 125 const intern_type* __from_end, const intern_type*& __from_next, 126 extern_type* __to, extern_type* __to_end, 127 extern_type*& __to_next) const 128 { 129 return this->do_out(__state, __from, __from_end, __from_next, 130 __to, __to_end, __to_next); 131 } 132 133 /** 134 * @brief Reset conversion state. 135 * 136 * Writes characters to output that would restore @a state to initial 137 * conditions. The idea is that if a partial conversion occurs, then 138 * the converting the characters written by this function would leave 139 * the state in initial conditions, rather than partial conversion 140 * state. It does this by calling codecvt::do_unshift(). 141 * 142 * For example, if 4 external characters always converted to 1 internal 143 * character, and input to in() had 6 external characters with state 144 * saved, this function would write two characters to the output and 145 * set the state to initialized conditions. 146 * 147 * The source and destination character sets are determined by the 148 * facet's locale, internal and external types. 149 * 150 * The result returned is a member of codecvt_base::result. If the 151 * state could be reset and data written, returns codecvt_base::ok. If 152 * no conversion is necessary, returns codecvt_base::noconv. If the 153 * output has insufficient space, returns codecvt_base::partial. 154 * Otherwise the reset failed and codecvt_base::error is returned. 155 * 156 * @param __state Persistent conversion state data. 157 * @param __to Start of output buffer. 158 * @param __to_end End of output buffer. 159 * @param __to_next Returns start of unused output area. 160 * @return codecvt_base::result. 161 */ 162 result 163 unshift(state_type& __state, extern_type* __to, extern_type* __to_end, 164 extern_type*& __to_next) const 165 { return this->do_unshift(__state, __to,__to_end,__to_next); } 166 167 /** 168 * @brief Convert from external to internal character set. 169 * 170 * Converts input string of extern_type to output string of 171 * intern_type. This is analogous to mbsrtowcs. It does this by 172 * calling codecvt::do_in. 173 * 174 * The source and destination character sets are determined by the 175 * facet's locale, internal and external types. 176 * 177 * The characters in [from,from_end) are converted and written to 178 * [to,to_end). from_next and to_next are set to point to the 179 * character following the last successfully converted character, 180 * respectively. If the result needed no conversion, from_next and 181 * to_next are not affected. 182 * 183 * The @a state argument should be initialized if the input is at the 184 * beginning and carried from a previous call if continuing 185 * conversion. There are no guarantees about how @a state is used. 186 * 187 * The result returned is a member of codecvt_base::result. If 188 * all the input is converted, returns codecvt_base::ok. If no 189 * conversion is necessary, returns codecvt_base::noconv. If 190 * the input ends early or there is insufficient space in the 191 * output, returns codecvt_base::partial. Otherwise the 192 * conversion failed and codecvt_base::error is returned. 193 * 194 * @param __state Persistent conversion state data. 195 * @param __from Start of input. 196 * @param __from_end End of input. 197 * @param __from_next Returns start of unconverted data. 198 * @param __to Start of output buffer. 199 * @param __to_end End of output buffer. 200 * @param __to_next Returns start of unused output area. 201 * @return codecvt_base::result. 202 */ 203 result 204 in(state_type& __state, const extern_type* __from, 205 const extern_type* __from_end, const extern_type*& __from_next, 206 intern_type* __to, intern_type* __to_end, 207 intern_type*& __to_next) const 208 { 209 return this->do_in(__state, __from, __from_end, __from_next, 210 __to, __to_end, __to_next); 211 } 212 213 int 214 encoding() const throw() 215 { return this->do_encoding(); } 216 217 bool 218 always_noconv() const throw() 219 { return this->do_always_noconv(); } 220 221 int 222 length(state_type& __state, const extern_type* __from, 223 const extern_type* __end, size_t __max) const 224 { return this->do_length(__state, __from, __end, __max); } 225 226 int 227 max_length() const throw() 228 { return this->do_max_length(); } 229 230 protected: 231 explicit 232 __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { } 233 234 virtual 235 ~__codecvt_abstract_base() { } 236 237 /** 238 * @brief Convert from internal to external character set. 239 * 240 * Converts input string of intern_type to output string of 241 * extern_type. This function is a hook for derived classes to change 242 * the value returned. @see out for more information. 243 */ 244 virtual result 245 do_out(state_type& __state, const intern_type* __from, 246 const intern_type* __from_end, const intern_type*& __from_next, 247 extern_type* __to, extern_type* __to_end, 248 extern_type*& __to_next) const = 0; 249 250 virtual result 251 do_unshift(state_type& __state, extern_type* __to, 252 extern_type* __to_end, extern_type*& __to_next) const = 0; 253 254 virtual result 255 do_in(state_type& __state, const extern_type* __from, 256 const extern_type* __from_end, const extern_type*& __from_next, 257 intern_type* __to, intern_type* __to_end, 258 intern_type*& __to_next) const = 0; 259 260 virtual int 261 do_encoding() const throw() = 0; 262 263 virtual bool 264 do_always_noconv() const throw() = 0; 265 266 virtual int 267 do_length(state_type&, const extern_type* __from, 268 const extern_type* __end, size_t __max) const = 0; 269 270 virtual int 271 do_max_length() const throw() = 0; 272 }; 273 274 /** 275 * @brief Primary class template codecvt. 276 * @ingroup locales 277 * 278 * NB: Generic, mostly useless implementation. 279 * 280 */ 281 template<typename _InternT, typename _ExternT, typename _StateT> 282 class codecvt 283 : public __codecvt_abstract_base<_InternT, _ExternT, _StateT> 284 { 285 public: 286 // Types: 287 typedef codecvt_base::result result; 288 typedef _InternT intern_type; 289 typedef _ExternT extern_type; 290 typedef _StateT state_type; 291 292 protected: 293 __c_locale _M_c_locale_codecvt; 294 295 public: 296 static locale::id id; 297 298 explicit 299 codecvt(size_t __refs = 0) 300 : __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs), 301 _M_c_locale_codecvt(0) 302 { } 303 304 explicit 305 codecvt(__c_locale __cloc, size_t __refs = 0); 306 307 protected: 308 virtual 309 ~codecvt() { } 310 311 virtual result 312 do_out(state_type& __state, const intern_type* __from, 313 const intern_type* __from_end, const intern_type*& __from_next, 314 extern_type* __to, extern_type* __to_end, 315 extern_type*& __to_next) const; 316 317 virtual result 318 do_unshift(state_type& __state, extern_type* __to, 319 extern_type* __to_end, extern_type*& __to_next) const; 320 321 virtual result 322 do_in(state_type& __state, const extern_type* __from, 323 const extern_type* __from_end, const extern_type*& __from_next, 324 intern_type* __to, intern_type* __to_end, 325 intern_type*& __to_next) const; 326 327 virtual int 328 do_encoding() const throw(); 329 330 virtual bool 331 do_always_noconv() const throw(); 332 333 virtual int 334 do_length(state_type&, const extern_type* __from, 335 const extern_type* __end, size_t __max) const; 336 337 virtual int 338 do_max_length() const throw(); 339 }; 340 341 template<typename _InternT, typename _ExternT, typename _StateT> 342 locale::id codecvt<_InternT, _ExternT, _StateT>::id; 343 344 /// class codecvt<char, char, mbstate_t> specialization. 345 template<> 346 class codecvt<char, char, mbstate_t> 347 : public __codecvt_abstract_base<char, char, mbstate_t> 348 { 349 friend class messages<char>; 350 351 public: 352 // Types: 353 typedef char intern_type; 354 typedef char extern_type; 355 typedef mbstate_t state_type; 356 357 protected: 358 __c_locale _M_c_locale_codecvt; 359 360 public: 361 static locale::id id; 362 363 explicit 364 codecvt(size_t __refs = 0); 365 366 explicit 367 codecvt(__c_locale __cloc, size_t __refs = 0); 368 369 protected: 370 virtual 371 ~codecvt(); 372 373 virtual result 374 do_out(state_type& __state, const intern_type* __from, 375 const intern_type* __from_end, const intern_type*& __from_next, 376 extern_type* __to, extern_type* __to_end, 377 extern_type*& __to_next) const; 378 379 virtual result 380 do_unshift(state_type& __state, extern_type* __to, 381 extern_type* __to_end, extern_type*& __to_next) const; 382 383 virtual result 384 do_in(state_type& __state, const extern_type* __from, 385 const extern_type* __from_end, const extern_type*& __from_next, 386 intern_type* __to, intern_type* __to_end, 387 intern_type*& __to_next) const; 388 389 virtual int 390 do_encoding() const throw(); 391 392 virtual bool 393 do_always_noconv() const throw(); 394 395 virtual int 396 do_length(state_type&, const extern_type* __from, 397 const extern_type* __end, size_t __max) const; 398 399 virtual int 400 do_max_length() const throw(); 401 }; 402 403 #ifdef _GLIBCXX_USE_WCHAR_T 404 /** @brief Class codecvt<wchar_t, char, mbstate_t> specialization. 405 * 406 * Converts between narrow and wide characters in the native character set 407 */ 408 template<> 409 class codecvt<wchar_t, char, mbstate_t> 410 : public __codecvt_abstract_base<wchar_t, char, mbstate_t> 411 { 412 friend class messages<wchar_t>; 413 414 public: 415 // Types: 416 typedef wchar_t intern_type; 417 typedef char extern_type; 418 typedef mbstate_t state_type; 419 420 protected: 421 __c_locale _M_c_locale_codecvt; 422 423 public: 424 static locale::id id; 425 426 explicit 427 codecvt(size_t __refs = 0); 428 429 explicit 430 codecvt(__c_locale __cloc, size_t __refs = 0); 431 432 protected: 433 virtual 434 ~codecvt(); 435 436 virtual result 437 do_out(state_type& __state, const intern_type* __from, 438 const intern_type* __from_end, const intern_type*& __from_next, 439 extern_type* __to, extern_type* __to_end, 440 extern_type*& __to_next) const; 441 442 virtual result 443 do_unshift(state_type& __state, 444 extern_type* __to, extern_type* __to_end, 445 extern_type*& __to_next) const; 446 447 virtual result 448 do_in(state_type& __state, 449 const extern_type* __from, const extern_type* __from_end, 450 const extern_type*& __from_next, 451 intern_type* __to, intern_type* __to_end, 452 intern_type*& __to_next) const; 453 454 virtual 455 int do_encoding() const throw(); 456 457 virtual 458 bool do_always_noconv() const throw(); 459 460 virtual 461 int do_length(state_type&, const extern_type* __from, 462 const extern_type* __end, size_t __max) const; 463 464 virtual int 465 do_max_length() const throw(); 466 }; 467 #endif //_GLIBCXX_USE_WCHAR_T 468 469 #if __cplusplus >= 201103L 470 /** @brief Class codecvt<char16_t, char, mbstate_t> specialization. 471 * 472 * Converts between UTF-16 and UTF-8. 473 */ 474 template<> 475 class codecvt<char16_t, char, mbstate_t> 476 : public __codecvt_abstract_base<char16_t, char, mbstate_t> 477 { 478 public: 479 // Types: 480 typedef char16_t intern_type; 481 typedef char extern_type; 482 typedef mbstate_t state_type; 483 484 public: 485 static locale::id id; 486 487 explicit 488 codecvt(size_t __refs = 0) 489 : __codecvt_abstract_base<char16_t, char, mbstate_t>(__refs) { } 490 491 protected: 492 virtual 493 ~codecvt(); 494 495 virtual result 496 do_out(state_type& __state, const intern_type* __from, 497 const intern_type* __from_end, const intern_type*& __from_next, 498 extern_type* __to, extern_type* __to_end, 499 extern_type*& __to_next) const; 500 501 virtual result 502 do_unshift(state_type& __state, 503 extern_type* __to, extern_type* __to_end, 504 extern_type*& __to_next) const; 505 506 virtual result 507 do_in(state_type& __state, 508 const extern_type* __from, const extern_type* __from_end, 509 const extern_type*& __from_next, 510 intern_type* __to, intern_type* __to_end, 511 intern_type*& __to_next) const; 512 513 virtual 514 int do_encoding() const throw(); 515 516 virtual 517 bool do_always_noconv() const throw(); 518 519 virtual 520 int do_length(state_type&, const extern_type* __from, 521 const extern_type* __end, size_t __max) const; 522 523 virtual int 524 do_max_length() const throw(); 525 }; 526 527 /** @brief Class codecvt<char32_t, char, mbstate_t> specialization. 528 * 529 * Converts between UTF-32 and UTF-8. 530 */ 531 template<> 532 class codecvt<char32_t, char, mbstate_t> 533 : public __codecvt_abstract_base<char32_t, char, mbstate_t> 534 { 535 public: 536 // Types: 537 typedef char32_t intern_type; 538 typedef char extern_type; 539 typedef mbstate_t state_type; 540 541 public: 542 static locale::id id; 543 544 explicit 545 codecvt(size_t __refs = 0) 546 : __codecvt_abstract_base<char32_t, char, mbstate_t>(__refs) { } 547 548 protected: 549 virtual 550 ~codecvt(); 551 552 virtual result 553 do_out(state_type& __state, const intern_type* __from, 554 const intern_type* __from_end, const intern_type*& __from_next, 555 extern_type* __to, extern_type* __to_end, 556 extern_type*& __to_next) const; 557 558 virtual result 559 do_unshift(state_type& __state, 560 extern_type* __to, extern_type* __to_end, 561 extern_type*& __to_next) const; 562 563 virtual result 564 do_in(state_type& __state, 565 const extern_type* __from, const extern_type* __from_end, 566 const extern_type*& __from_next, 567 intern_type* __to, intern_type* __to_end, 568 intern_type*& __to_next) const; 569 570 virtual 571 int do_encoding() const throw(); 572 573 virtual 574 bool do_always_noconv() const throw(); 575 576 virtual 577 int do_length(state_type&, const extern_type* __from, 578 const extern_type* __end, size_t __max) const; 579 580 virtual int 581 do_max_length() const throw(); 582 }; 583 584 #ifdef _GLIBCXX_USE_CHAR8_T 585 /** @brief Class codecvt<char16_t, char8_t, mbstate_t> specialization. 586 * 587 * Converts between UTF-16 and UTF-8. 588 */ 589 template<> 590 class codecvt<char16_t, char8_t, mbstate_t> 591 : public __codecvt_abstract_base<char16_t, char8_t, mbstate_t> 592 { 593 public: 594 // Types: 595 typedef char16_t intern_type; 596 typedef char8_t extern_type; 597 typedef mbstate_t state_type; 598 599 public: 600 static locale::id id; 601 602 explicit 603 codecvt(size_t __refs = 0) 604 : __codecvt_abstract_base<char16_t, char8_t, mbstate_t>(__refs) { } 605 606 protected: 607 virtual 608 ~codecvt(); 609 610 virtual result 611 do_out(state_type& __state, const intern_type* __from, 612 const intern_type* __from_end, const intern_type*& __from_next, 613 extern_type* __to, extern_type* __to_end, 614 extern_type*& __to_next) const; 615 616 virtual result 617 do_unshift(state_type& __state, 618 extern_type* __to, extern_type* __to_end, 619 extern_type*& __to_next) const; 620 621 virtual result 622 do_in(state_type& __state, 623 const extern_type* __from, const extern_type* __from_end, 624 const extern_type*& __from_next, 625 intern_type* __to, intern_type* __to_end, 626 intern_type*& __to_next) const; 627 628 virtual 629 int do_encoding() const throw(); 630 631 virtual 632 bool do_always_noconv() const throw(); 633 634 virtual 635 int do_length(state_type&, const extern_type* __from, 636 const extern_type* __end, size_t __max) const; 637 638 virtual int 639 do_max_length() const throw(); 640 }; 641 642 /** @brief Class codecvt<char32_t, char8_t, mbstate_t> specialization. 643 * 644 * Converts between UTF-32 and UTF-8. 645 */ 646 template<> 647 class codecvt<char32_t, char8_t, mbstate_t> 648 : public __codecvt_abstract_base<char32_t, char8_t, mbstate_t> 649 { 650 public: 651 // Types: 652 typedef char32_t intern_type; 653 typedef char8_t extern_type; 654 typedef mbstate_t state_type; 655 656 public: 657 static locale::id id; 658 659 explicit 660 codecvt(size_t __refs = 0) 661 : __codecvt_abstract_base<char32_t, char8_t, mbstate_t>(__refs) { } 662 663 protected: 664 virtual 665 ~codecvt(); 666 667 virtual result 668 do_out(state_type& __state, const intern_type* __from, 669 const intern_type* __from_end, const intern_type*& __from_next, 670 extern_type* __to, extern_type* __to_end, 671 extern_type*& __to_next) const; 672 673 virtual result 674 do_unshift(state_type& __state, 675 extern_type* __to, extern_type* __to_end, 676 extern_type*& __to_next) const; 677 678 virtual result 679 do_in(state_type& __state, 680 const extern_type* __from, const extern_type* __from_end, 681 const extern_type*& __from_next, 682 intern_type* __to, intern_type* __to_end, 683 intern_type*& __to_next) const; 684 685 virtual 686 int do_encoding() const throw(); 687 688 virtual 689 bool do_always_noconv() const throw(); 690 691 virtual 692 int do_length(state_type&, const extern_type* __from, 693 const extern_type* __end, size_t __max) const; 694 695 virtual int 696 do_max_length() const throw(); 697 }; 698 #endif // _GLIBCXX_USE_CHAR8_T 699 700 #endif // C++11 701 702 /// class codecvt_byname [22.2.1.6]. 703 template<typename _InternT, typename _ExternT, typename _StateT> 704 class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> 705 { 706 public: 707 explicit 708 codecvt_byname(const char* __s, size_t __refs = 0) 709 : codecvt<_InternT, _ExternT, _StateT>(__refs) 710 { 711 if (__builtin_strcmp(__s, "C") != 0 712 && __builtin_strcmp(__s, "POSIX") != 0) 713 { 714 this->_S_destroy_c_locale(this->_M_c_locale_codecvt); 715 this->_S_create_c_locale(this->_M_c_locale_codecvt, __s); 716 } 717 } 718 719 #if __cplusplus >= 201103L 720 explicit 721 codecvt_byname(const string& __s, size_t __refs = 0) 722 : codecvt_byname(__s.c_str(), __refs) { } 723 #endif 724 725 protected: 726 virtual 727 ~codecvt_byname() { } 728 }; 729 730 #if __cplusplus >= 201103L 731 template<> 732 class codecvt_byname<char16_t, char, mbstate_t> 733 : public codecvt<char16_t, char, mbstate_t> 734 { 735 public: 736 explicit 737 codecvt_byname(const char*, size_t __refs = 0) 738 : codecvt<char16_t, char, mbstate_t>(__refs) { } 739 740 explicit 741 codecvt_byname(const string& __s, size_t __refs = 0) 742 : codecvt_byname(__s.c_str(), __refs) { } 743 744 protected: 745 virtual 746 ~codecvt_byname() { } 747 }; 748 749 template<> 750 class codecvt_byname<char32_t, char, mbstate_t> 751 : public codecvt<char32_t, char, mbstate_t> 752 { 753 public: 754 explicit 755 codecvt_byname(const char*, size_t __refs = 0) 756 : codecvt<char32_t, char, mbstate_t>(__refs) { } 757 758 explicit 759 codecvt_byname(const string& __s, size_t __refs = 0) 760 : codecvt_byname(__s.c_str(), __refs) { } 761 762 protected: 763 virtual 764 ~codecvt_byname() { } 765 }; 766 767 #if defined(_GLIBCXX_USE_CHAR8_T) 768 template<> 769 class codecvt_byname<char16_t, char8_t, mbstate_t> 770 : public codecvt<char16_t, char8_t, mbstate_t> 771 { 772 public: 773 explicit 774 codecvt_byname(const char*, size_t __refs = 0) 775 : codecvt<char16_t, char8_t, mbstate_t>(__refs) { } 776 777 explicit 778 codecvt_byname(const string& __s, size_t __refs = 0) 779 : codecvt_byname(__s.c_str(), __refs) { } 780 781 protected: 782 virtual 783 ~codecvt_byname() { } 784 }; 785 786 template<> 787 class codecvt_byname<char32_t, char8_t, mbstate_t> 788 : public codecvt<char32_t, char8_t, mbstate_t> 789 { 790 public: 791 explicit 792 codecvt_byname(const char*, size_t __refs = 0) 793 : codecvt<char32_t, char8_t, mbstate_t>(__refs) { } 794 795 explicit 796 codecvt_byname(const string& __s, size_t __refs = 0) 797 : codecvt_byname(__s.c_str(), __refs) { } 798 799 protected: 800 virtual 801 ~codecvt_byname() { } 802 }; 803 #endif 804 805 #endif // C++11 806 807 // Inhibit implicit instantiations for required instantiations, 808 // which are defined via explicit instantiations elsewhere. 809 #if _GLIBCXX_EXTERN_TEMPLATE 810 extern template class codecvt_byname<char, char, mbstate_t>; 811 812 extern template 813 const codecvt<char, char, mbstate_t>& 814 use_facet<codecvt<char, char, mbstate_t> >(const locale&); 815 816 extern template 817 bool 818 has_facet<codecvt<char, char, mbstate_t> >(const locale&); 819 820 #ifdef _GLIBCXX_USE_WCHAR_T 821 extern template class codecvt_byname<wchar_t, char, mbstate_t>; 822 823 extern template 824 const codecvt<wchar_t, char, mbstate_t>& 825 use_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&); 826 827 extern template 828 bool 829 has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&); 830 #endif 831 832 #if __cplusplus >= 201103L 833 extern template class codecvt_byname<char16_t, char, mbstate_t>; 834 extern template class codecvt_byname<char32_t, char, mbstate_t>; 835 836 #if defined(_GLIBCXX_USE_CHAR8_T) 837 extern template class codecvt_byname<char16_t, char8_t, mbstate_t>; 838 extern template class codecvt_byname<char32_t, char8_t, mbstate_t>; 839 #endif 840 841 #endif 842 843 #endif 844 845 _GLIBCXX_END_NAMESPACE_VERSION 846 } // namespace std 847 848 #pragma GCC diagnostic pop 849 #endif // _CODECVT_H