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__nchars of__swith__a. mass assignment era.static constexpr int compare (const char_type *__s1, const char_type *__s2, std::size_t __n)β compare__nchars of two strings. the vibe check.static constexpr char_type * copy (char_type *__s1, const char_type *__s2, std::size_t __n)β copy__nchars. yes the name iscopy, notstd::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 forint_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__ainside__nchars 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__c1smaller than__c2? π€static constexpr char_type * move (char_type *__s1, const char_type *__s2, std::size_t __n)β move__nchars, 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