__GNU_CXX::CHAR_TRAITS(3)

πŸ’– __gnu_cxx::char_traits< _CharT > πŸ’–

okay bestie, welcome to the Library Functions Manual ✨ this one's about a little base class that lives in __gnu_cxx and exists purely so that std::char_traits can be built on top of it. yes, it's giving "scaffolding", but it's iconic scaffolding. let's get into it 🫢


🌸 NAME 🌸

__gnu_cxx::char_traits< _CharT > β€” the base class used to implement std::char_traits. literally that's the whole job description. periodt πŸ’…


✨ SYNOPSIS ✨

#include <char_traits.h>

Inherited by std::int_type< char >, std::pos_type< char >, std::off_type< char >, std::char_traits< __gnu_cxx::character< _Value, _Int, _St > >, std::char_traits< char >, std::char_traits< char16_t >, std::char_traits< char32_t >, std::char_traits< wchar_t >, and std::char_traits< _CharT >.

like... that's a whole family tree right there. not me counting the relatives 😭


πŸŽ€ Public Types πŸŽ€

  • typedef _CharT char_type
  • using comparison_category
  • typedef _Char_types< _CharT >::int_type int_type
  • typedef _Char_types< _CharT >::off_type off_type
  • typedef _Char_types< _CharT >::pos_type pos_type
  • typedef _Char_types< _CharT >::state_type state_type

the type aliases ate and left no crumbs πŸ‘‘


πŸ”₯ Static Public Member Functions πŸ”₯

  • static constexpr void assign (char_type &__c1, const char_type &__c2)
  • static constexpr char_type * assign (char_type *__s, std::size_t __n, char_type __a)
  • static constexpr int compare (const char_type *__s1, const char_type *__s2, std::size_t __n)
  • static constexpr char_type * copy (char_type *__s1, const char_type *__s2, std::size_t __n)
  • static constexpr int_type eof ()
  • static constexpr bool eq (const char_type &__c1, const char_type &__c2)
  • static constexpr bool eq_int_type (const int_type &__c1, const int_type &__c2)
  • static constexpr const char_type * find (const char_type *__s, std::size_t __n, const char_type &__a)
  • static constexpr std::size_t length (const char_type *__s)
  • static constexpr bool lt (const char_type &__c1, const char_type &__c2)
  • static constexpr char_type * move (char_type *__s1, const char_type *__s2, std::size_t __n)
  • static constexpr int_type not_eof (const int_type &__c)
  • static constexpr char_type to_char_type (const int_type &__c)
  • static constexpr int_type to_int_type (const char_type &__c)

fourteen functions, all static constexpr, all serving πŸ’… no cap, they're all doing the most in the least dramatic way possible.


πŸ¦‹ Detailed Description πŸ¦‹

template<typename _CharT>
    struct __gnu_cxx::char_traits< _CharT >

"Base class used to implement std::char_traits."


πŸ™ˆ Note πŸ™ˆ

bestie, listen carefully: for any given actual character type, this definition is probably wrong. 😭 (Most of the member functions are likely to be right, but the int_type and state_type typedefs, and the eof() member function, are likely to be wrong.)

so why does it even exist?? because it's supposed to be specialized, that's why!! the whole reason this class is here is so users can specialize it. classes in namespace std may not be specialized for fundamental types, but classes in namespace __gnu_cxx may be. that's the loophole, and it's lowkey genius 🧚


🌈 See 🌈

https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types for advice on how to make use of this class for unusual character types. also, check out include/ext/pod_char_traits.h β€” it's giving "required reading" πŸ“šβœ¨


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code.


and that's the whole page, bestie 🫢 this was libstdc++'s contribution to the manual, and if you made it to the end you're officially a main character in the character-traits cinematic universe. iykyk πŸ’œ slay, stay specialized, and don't forget to check include/ext/pod_char_traits.h on your way out πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms