STD::CHAR_TRAITS(3)

πŸ’– std::char_traits< _CharT > β€” Library Functions Manual, section 3 πŸ’–

okay bestie, pull up a chair, we're reading a C++ manpage together and honestly? it's giving foundational. this is std::char_traits< _CharT >(3), straight out of the Library Functions Manual, and it's literally the blueprint every string type in libstdc++ builds its whole personality on. 🌸


✨ NAME ✨

std::char_traits< _CharT > β€” the Basis for explicit traits specializations. that's it, that's the whole job description. πŸŽ€


✨ SYNOPSIS ✨

#include <string>
  • Inherits __gnu_cxx::char_traits< _CharT >. yes she's got a parent, she's not doing this alone. 🫢
  • Inherited by __gnu_cxx::encoding_char_traits< _CharT >. and she's a mother too, iconic lineage honestly. πŸ‘‘

🌈 Public Types 🌈

  • typedef _CharT char_type β€” the character type. the main character, literally. ✨
  • using comparison_category β€” the comparison category, hanging out, being a using-declaration. πŸ’…
  • typedef _Char_types< _CharT >::int_type int_type β€” int type, inherited from _Char_types< _CharT >.
  • typedef _Char_types< _CharT >::off_type off_type β€” off type, also from _Char_types< _CharT >.
  • typedef _Char_types< _CharT >::pos_type pos_type β€” pos type, again from _Char_types< _CharT >.
  • typedef _Char_types< _CharT >::state_type state_type β€” state type, once more from _Char_types< _CharT >.

πŸ¦‹ Static Public Member Functions πŸ¦‹

these are all static constexpr, so they're free, they're fast, and they're not taking your this pointer. no cap. πŸ”₯

  • static constexpr void assign (char_type &__c1, const char_type &__c2) β€” assign one char to another. set it and forget it.
  • static constexpr char_type * assign (char_type *__s, std::size_t __n, char_type __a) β€” fill __n chars of __s with __a. mass assignment era.
  • static constexpr int compare (const char_type *__s1, const char_type *__s2, std::size_t __n) β€” compare __n chars of two strings. the vibe check.
  • static constexpr char_type * copy (char_type *__s1, const char_type *__s2, std::size_t __n) β€” copy __n chars. yes the name is copy, not std::copy, don't @ me.
  • static constexpr int_type eof () β€” returns the end-of-file value. the finale, the end credits. 😭
  • static constexpr bool eq (const char_type &__c1, const char_type &__c2) β€” are these two chars equal? yes or yes. πŸ’–
  • static constexpr bool eq_int_type (const int_type &__c1, const int_type &__c2) β€” same question but for int_type. equality but make it int.
  • static constexpr const char_type * find (const char_type *__s, std::size_t __n, const char_type &__a) β€” hunt for __a inside __n chars of __s. detective mode. πŸ”
  • static constexpr std::size_t length (const char_type *__s) β€” how long is __s? she'll tell you. πŸ“
  • static constexpr bool lt (const char_type &__c1, const char_type &__c2) β€” less-than. is __c1 smaller than __c2? 🀏
  • static constexpr char_type * move (char_type *__s1, const char_type *__s2, std::size_t __n) β€” move __n chars, overlaps safe. she can handle messy situations. πŸ’…
  • static constexpr int_type not_eof (const int_type &__c) β€” returns something that is not the eof value. the anti-finale.
  • static constexpr char_type to_char_type (const int_type &__c) β€” int type goes in, char type comes out. transformation arc. πŸ¦‹
  • static constexpr int_type to_int_type (const char_type &__c) β€” char type goes in, int type comes out. the reverse glow-up.

✨ Detailed Description ✨

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

Basis for explicit traits specializations.

Note πŸ“Œ For any given actual character type, this definition is probably wrong. Since this is just a thin wrapper around __gnu_cxx::char_traits, it is possible to achieve a more appropriate definition by specializing __gnu_cxx::char_traits.

so yeah, out of the box she's a thin wrapper and she knows she might be wrong for your weird char type, and honestly? self-aware queen. if you need her to actually behave right, you go specialize __gnu_cxx::char_traits yourself. 🧚

See 🌟 https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types β€” that's the link with advice on how to make use of this class for unusual character types. also, check out include/ext/pod_string. go on, click it, i'll wait. πŸ’œ


✨ Author ✨

Generated automatically by Doxygen for libstdc++ from the source code. she wasn't written by a human hand, she was generated, and she still ate. πŸ€–πŸ’…


and that's the whole page bestie β€” brought to you by libstdc++, from the std::char_...< _CharT >(3) page, in the Library Functions Manual. no cap, go specialize some traits, ily, bye! πŸŽ€βœ¨πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ 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
  • centos-stream 10: gcc-toolset-15-libstdc++-docs 15.2.1-8.1.el10 Β· 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
  • centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· 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
  • centos-stream 10: libstdc++-docs 14.4.1-4.el10 Β· 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 43: libstdc++-docs 15.2.1-2.fc43 Β· 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 43: libstdc++-docs 15.3.1-1.fc43 Β· 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.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