GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::wstring_convert::~wstring_convert(3) C++ Standard Libary std::wstring_convert::~wstring_convert(3)

std::wstring_convert::~wstring_convert - std::wstring_convert::~wstring_convert


~wstring_convert();


Destroys the wstring_convert object and deletes the pointer to the conversion facet.


Some implementations are able to delete any facet, including the locale-specific
facets with protected destructors. Other implementations require the facet to have a
public destructor, similar to the locale-independent facets from <codecvt>. This is
LWG issue 721

// Run this code


#include <locale>
#include <utility>
#include <codecvt>


// utility wrapper to adapt locale-bound facets for wstring/wbuffer convert
template<class Facet>
struct deletable_facet : Facet
{
template<class ...Args>
deletable_facet(Args&& ...args) : Facet(std::forward<Args>(args)...) {}
~deletable_facet() {}
};


int main()
{
// GB18030 / UCS4 conversion, using locale-based facet directly
// typedef std::codecvt_byname<char32_t, char, std::mbstate_t> gbfacet_t;
// Compiler error: "calling a protected destructor of codecvt_byname<> in ~wstring_convert"
// std::wstring_convert<gbfacet_t> gbto32(new gbfacet_t("zh_CN.gb18030"));


// GB18030 / UCS4 conversion facet using a facet with public destructor
typedef deletable_facet<std::codecvt_byname<char32_t, char, std::mbstate_t>> gbfacet_t;
std::wstring_convert<gbfacet_t> gbto32(new gbfacet_t("zh_CN.gb18030"));
} // destructor called here

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.