---
name: "std::char_traits"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::char_traits"
---

# std::char\_traits(3)

Basis for explicit traits specializations.

## NAME

std::char\_traits\< \_CharT \> - Basis for explicit traits specializations.

## SYNOPSIS

\#include \<string\>

Inherits **\_\_gnu\_cxx::char\_traits\< \_CharT \>**.

Inherited by **\_\_gnu\_cxx::encoding\_char\_traits\< \_CharT \>**.

### 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**\

### 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)\

## 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.

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\_string.

## Author

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