---
name: "std::collate_byname"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::collate_byname/3cxx"
---

# std::collate\_byname(3cxx)

class collate\_byname \[22.2.4.2\].

## NAME

std::collate\_byname\< \_CharT \> - class collate\_byname \[22.2.4.2\].

## SYNOPSIS

`#include <locale>`

Inherits **std::collate\< \_CharT \>**.

### Public Types

**typedef** \_CharT **char\_type**\
 Public typedefs.  **typedef** **basic\_string**\< \_CharT \> **string\_type**\
 Public typedefs.

### Public Member Functions

**collate\_byname** (const char \***\_\_s**, size\_t **\_\_refs**=0)\
 **collate\_byname** (const **string** &**\_\_s**, size\_t **\_\_refs**=0)\
 int **\_M\_compare** (const \_CharT \*, const \_CharT \*) const  **throw** ()\
 int **\_M\_compare** (const char \*, const char \*) const **throw**()\
 int **\_M\_compare** (const wchar\_t \*, const wchar\_t \*) const **throw**()\
 size\_t **\_M\_transform** (\_CharT \*, const \_CharT \*, size\_t) const  **throw** ()\
 size\_t **\_M\_transform** (char \*, const char \*, size\_t) const **throw**()\
 size\_t **\_M\_transform** (wchar\_t \*, const wchar\_t \*, size\_t) const **throw**()\
 int **compare** (const \_CharT \***\_\_lo1**, const \_CharT \***\_\_hi1**, const \_CharT \***\_\_lo2**, const \_CharT \***\_\_hi2**) const\
 Compare two strings.  long **hash** (const \_CharT \***\_\_lo**, const \_CharT \***\_\_hi**) const\
 Return hash of a string.  **string\_type** **transform** (const \_CharT \***\_\_lo**, const \_CharT \***\_\_hi**) const\
 Transform string to comparable form.

### Static Public Attributes

**static** **locale::id** **id**\
 Numpunct facet id.

### Protected Member Functions

**virtual** int **do\_compare** (const \_CharT \***\_\_lo1**, const \_CharT \***\_\_hi1**, const \_CharT \***\_\_lo2**, const \_CharT \***\_\_hi2**) const\
 Compare two strings.  **virtual** long **do\_hash** (const \_CharT \***\_\_lo**, const \_CharT \***\_\_hi**) const\
 Return hash of a string.  **virtual** **string\_type** **do\_transform** (const \_CharT \***\_\_lo**, const \_CharT \***\_\_hi**) const\
 Transform string to comparable form.

### Static Protected Member Functions

**static** \_\_c\_locale **\_S\_clone\_c\_locale** (\_\_c\_locale &**\_\_cloc**)  **throw** ()\
 **static** **void** **\_S\_create\_c\_locale** (\_\_c\_locale &**\_\_cloc**, const char \***\_\_s**, \_\_c\_locale **\_\_old**=0)\
 **static** **void** **\_S\_destroy\_c\_locale** (\_\_c\_locale &**\_\_cloc**)\
 **static** \_\_c\_locale **\_S\_get\_c\_locale** ()\
 **static** const char \* **\_S\_get\_c\_name** ()  **throw** ()\
 **static** \_\_c\_locale **\_S\_lc\_ctype\_c\_locale** (\_\_c\_locale **\_\_cloc**, const char \***\_\_s**)\

### Protected Attributes

\_\_c\_locale **\_M\_c\_locale\_collate**\

## Detailed Description

### template\<typename \_CharT\>

class std::collate\_byname\< \_CharT \>"class collate\_byname \[22.2.4.2\].

## Member Typedef Documentation

### template\<typename \_CharT \> typedef \_CharT std::collate\_byname\< \_CharT \>::char\_type

Public typedefs.

### template\<typename \_CharT \> typedef basic\_string\<\_CharT\> std::collate\_byname\< \_CharT \>::string\_type

Public typedefs.

## Member Function Documentation

### template\<typename \_CharT \> int std::collate\< \_CharT \>::compare (const \_CharT \* \_\_lo1, const \_CharT \* \_\_hi1, const \_CharT \* \_\_lo2, const \_CharT \* \_\_hi2) const` [inline]`, ` [inherited]`

Compare two strings. This function compares two strings and returns the result by calling collate::do\_compare().

**Parameters**

*\_\_lo1* Start of string 1. \
 *\_\_hi1* End of string 1. \
 *\_\_lo2* Start of string 2. \
 *\_\_hi2* End of string 2.

**Returns**

1 if string1 \> string2, -1 if string1 \< string2, else 0.

### template\<typename \_CharT \> int std::collate\< \_CharT \>::do\_compare (const \_CharT \* \_\_lo1, const \_CharT \* \_\_hi1, const \_CharT \* \_\_lo2, const \_CharT \* \_\_hi2) const` [protected]`, ` [virtual]`, ` [inherited]`

Compare two strings. This function is a hook for derived classes to change the value returned.

**See also**

compare().

**Parameters**

*\_\_lo1* Start of string 1. \
 *\_\_hi1* End of string 1. \
 *\_\_lo2* Start of string 2. \
 *\_\_hi2* End of string 2.

**Returns**

1 if string1 \> string2, -1 if string1 \< string2, else 0.

### template\<typename \_CharT \> long std::collate\< \_CharT \>::do\_hash (const \_CharT \* \_\_lo, const \_CharT \* \_\_hi) const` [protected]`, ` [virtual]`, ` [inherited]`

Return hash of a string. This function computes and returns a hash on the input string. This function is a hook for derived classes to change the value returned.

**Parameters**

*\_\_lo* Start of string. \
 *\_\_hi* End of string.

**Returns**

Hash value.

### template\<typename \_CharT \> collate\< \_CharT \>::string\_type std::collate\< \_CharT \>::do\_transform (const \_CharT \* \_\_lo, const \_CharT \* \_\_hi) const` [protected]`, ` [virtual]`, ` [inherited]`

Transform string to comparable form. This function is a hook for derived classes to change the value returned.

**Parameters**

*\_\_lo* Start. \
 *\_\_hi* End.

**Returns**

transformed string.

### template\<typename \_CharT \> long std::collate\< \_CharT \>::hash (const \_CharT \* \_\_lo, const \_CharT \* \_\_hi) const` [inline]`, ` [inherited]`

Return hash of a string. This function computes and returns a hash on the input string. It does so by returning collate::do\_hash().

**Parameters**

*\_\_lo* Start of string. \
 *\_\_hi* End of string.

**Returns**

Hash value.

### template\<typename \_CharT \> string\_type std::collate\< \_CharT \>::transform (const \_CharT \* \_\_lo, const \_CharT \* \_\_hi) const` [inline]`, ` [inherited]`

Transform string to comparable form. This function is a wrapper for strxfrm functionality. It takes the input string and returns a modified string that can be directly compared to other transformed strings. In the C locale, this function just returns a copy of the input string. In some other locales, it may replace two chars with one, change a char for another, etc. It does so by returning collate::do\_transform().

**Parameters**

*\_\_lo* Start of string. \
 *\_\_hi* End of string.

**Returns**

Transformed string\_type.

## Member Data Documentation

### template\<typename \_CharT \> locale::id std::collate\< \_CharT \>::id` [static]`, ` [inherited]`

Numpunct facet id.

## Author

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