---
name: "std::locale_id"
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::locale_id/3cxx"
---

# std::locale\_id(3cxx)

Facet ID class.

## NAME

std::locale::id - Facet ID class.

## SYNOPSIS

`#include <locale>`

### Public Member Functions

**id** ()\
 Constructor.  size\_t **\_M\_id** () const  **throw** ()\

### Friends

template\<**typename** **\_Facet** \> bool **has\_facet** (const **locale** &)  **throw** ()\
 Test for the presence of a facet.  **class** **locale**\
 **class** **locale::\_Impl**\
 template\<**typename** **\_Facet** \> const **\_Facet** & **use\_facet** (const **locale** &)\
 Return a facet.

## Detailed Description

Facet ID class.

The ID class provides facets with an index used to identify them. Every facet class must define a public static member locale::id, or be derived from a facet that provides this member, otherwise the facet cannot be used in a locale. The locale::id ensures that each class type gets a unique identifier.

## Constructor & Destructor Documentation

### std::locale::id::id ()` [inline]`

Constructor.

## Friends And Related Symbol Documentation

### template\<typename \_Facet \> bool has\_facet (const locale &)` [friend]`

Test for the presence of a facet. has\_facet tests the locale argument for the presence of the facet type provided as the template parameter. Facets derived from the facet parameter will also return true.

**Template Parameters**

*\_Facet* The facet type to test the presence of.

**Parameters**

*\_\_loc* The locale to test.

**Returns**

true if `__loc` contains a facet of type \_Facet, else false.

### template\<typename \_Facet \> const \_Facet & use\_facet (const locale &)` [friend]`

Return a facet. use\_facet looks for and returns a reference to a facet of type Facet where Facet is the template parameter. If has\_facet(locale) is true, there is a suitable facet to return. It throws std::bad\_cast if the locale doesn't contain a facet of type Facet.

**Template Parameters**

*\_Facet* The facet type to access.

**Parameters**

*\_\_loc* The locale to use.

**Returns**

Reference to facet of type Facet.

**Exceptions**

*std::bad\_cast* if `__loc` doesn't contain a facet of type \_Facet.

## Author

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