# std::codecvt<InternT,ExternT,StateT>::~codecvt

> C++ Atlas: `cppatlas.com/w/cpp/locale/codecvt/~codecvt` | Source: https://en.cppreference.com/w/cpp/locale/codecvt/~codecvt | Domain: Localization

Destructs a std::codecvt facet. This destructor is protected and virtual (due to base class destructor being virtual).

## Official Specification Summary (cppreference)

```cpp
// Defined in header <locale>
protected: ~codecvt();
```

Destructs a `std::codecvt` facet. This destructor is protected and virtual (due to base class destructor being virtual). An object of type `std::codecvt`, like most facets, can only be destroyed when the last `std::locale` object that implements this facet goes out of scope or if a user-defined class is derived from `std::codecvt` and implements a public destructor.

### Example

```cpp
#include <iostream>
#include <locale>

struct Destructible_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t>
{
    Destructible_codecvt(std::size_t refs = 0) : codecvt(refs) {}
    // note: the implicit destructor is public
};

int main()
{
    Destructible_codecvt dc;
    // std::codecvt<wchar_t> c; // compile error: protected destructor
}
```

---
Attribution: content from https://en.cppreference.com/w/cpp/locale/codecvt/~codecvt (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.