namespace std {
class locale {
public:
// types:
class facet;
class id;
using category = int;
static const category // values assigned here are for exposition only
none = 0,
collate = 0x010, ctype = 0x020,
monetary = 0x040, numeric = 0x080,
time = 0x100, messages = 0x200,
all = collate | ctype | monetary | numeric | time | messages;
// construct/copy/destroy:
locale() noexcept;
locale(const locale& other) noexcept;
explicit locale(const char* std_name);
explicit locale(const string& std_name);
locale(const locale& other, const char* std_name, category);
locale(const locale& other, const string& std_name, category);
template <class Facet> locale(const locale& other, Facet* f);
locale(const locale& other, const locale& one, category);
~locale(); // not virtual
const locale& operator=(const locale& other) noexcept;
template <class Facet> locale combine(const locale& other) const;
// locale operations:
basic_string<char> name() const;
bool operator==(const locale& other) const;
bool operator!=(const locale& other) const;
template <class charT, class traits, class Allocator>
bool operator()(const basic_string<charT, traits, Allocator>& s1,
const basic_string<charT, traits, Allocator>& s2) const;
// global locale objects:
static locale global(const locale&);
static const locale& classic();
};
}
template <class charT, class traits>
basic_ostream<charT, traits>&
operator<< (basic_ostream<charT, traits>& s, Date d) {
typename basic_ostream<charT, traits>::sentry cerberos(s);
if (cerberos) {
ios_base::iostate err = ios_base::iostate::goodbit;
tm tmbuf; d.extract(tmbuf);
use_facet<time_put<charT, ostreambuf_iterator<charT, traits>> >(
s.getloc()).put(s, s, s.fill(), err, &tmbuf, 'x');
s.setstate(err); // might throw
}
return s;
} — end exampleusing category = int;
(collate | ctype | monetary | numeric | time | messages | all) == all
Category | Includes facets |
collate | collate<char>, collate<wchar_t> |
ctype | ctype<char>, ctype<wchar_t> |
codecvt<char, char, mbstate_t> | |
codecvt<char16_t, char, mbstate_t> | |
codecvt<char32_t, char, mbstate_t> | |
codecvt<wchar_t, char, mbstate_t> | |
monetary | moneypunct<char>, moneypunct<wchar_t> |
moneypunct<char, true>, moneypunct<wchar_t, true> | |
money_get<char>, money_get<wchar_t> | |
money_put<char>, money_put<wchar_t> | |
numeric | numpunct<char>, numpunct<wchar_t> |
num_get<char>, num_get<wchar_t> | |
num_put<char>, num_put<wchar_t> | |
time | time_get<char>, time_get<wchar_t> |
time_put<char>, time_put<wchar_t> | |
messages | messages<char>, messages<wchar_t> |
Category | Includes facets |
collate | collate_byname<char>, collate_byname<wchar_t> |
ctype | ctype_byname<char>, ctype_byname<wchar_t> |
codecvt_byname<char, char, mbstate_t> | |
codecvt_byname<char16_t, char, mbstate_t> | |
codecvt_byname<char32_t, char, mbstate_t> | |
codecvt_byname<wchar_t, char, mbstate_t> | |
monetary | moneypunct_byname<char, International> |
moneypunct_byname<wchar_t, International> | |
money_get<C, InputIterator> | |
money_put<C, OutputIterator> | |
numeric | numpunct_byname<char>, numpunct_byname<wchar_t> |
num_get<C, InputIterator>, num_put<C, OutputIterator> | |
time | time_get<char, InputIterator> |
time_get_byname<char, InputIterator> | |
time_get<wchar_t, InputIterator> | |
time_get_byname<wchar_t, InputIterator> | |
time_put<char, OutputIterator> | |
time_put_byname<char, OutputIterator> | |
time_put<wchar_t, OutputIterator> | |
time_put_byname<wchar_t, OutputIterator> | |
messages | messages_byname<char>, messages_byname<wchar_t> |
namespace std {
class locale::facet {
protected:
explicit facet(size_t refs = 0);
virtual ~facet();
facet(const facet&) = delete;
void operator=(const facet&) = delete;
};
}
namespace std {
class locale::id {
public:
id();
void operator=(const id&) = delete;
id(const id&) = delete;
};
}locale() noexcept;
locale(const locale& other) noexcept;
explicit locale(const char* std_name);
explicit locale(const string& std_name);
locale(const locale& other, const char* std_name, category);
locale(const locale& other, const string& std_name, category cat);
template <class Facet> locale(const locale& other, Facet* f);
locale(const locale& other, const locale& one, category cats);
const locale& operator=(const locale& other) noexcept;
~locale();
template <class Facet> locale combine(const locale& other) const;
basic_string<char> name() const;
bool operator==(const locale& other) const;
bool operator!=(const locale& other) const;
template <class charT, class traits, class Allocator>
bool operator()(const basic_string<charT, traits, Allocator>& s1,
const basic_string<charT, traits, Allocator>& s2) const;
use_facet<collate<charT>>(*this).compare(s1.data(), s1.data() + s1.size(),
s2.data(), s2.data() + s2.size()) < 0std::sort(v.begin(), v.end(), loc);— end example
static locale global(const locale& loc);
setlocale(LC_ALL, loc.name().c_str());
static const locale& classic();
template <class Facet> const Facet& use_facet(const locale& loc);
template <class Facet> bool has_facet(const locale& loc) noexcept;
template <class charT> bool isspace (charT c, const locale& loc);
template <class charT> bool isprint (charT c, const locale& loc);
template <class charT> bool iscntrl (charT c, const locale& loc);
template <class charT> bool isupper (charT c, const locale& loc);
template <class charT> bool islower (charT c, const locale& loc);
template <class charT> bool isalpha (charT c, const locale& loc);
template <class charT> bool isdigit (charT c, const locale& loc);
template <class charT> bool ispunct (charT c, const locale& loc);
template <class charT> bool isxdigit(charT c, const locale& loc);
template <class charT> bool isalnum (charT c, const locale& loc);
template <class charT> bool isgraph (charT c, const locale& loc);
template <class charT> bool isblank (charT c, const locale& loc);
use_facet<ctype<charT>>(loc).is(ctype_base::F, c)template <class charT> charT toupper(charT c, const locale& loc);
template <class charT> charT tolower(charT c, const locale& loc);