Namespaces
Variants

Standard library header <locale>

From cppreference.net
Standard library headers

此头文件是 文本处理 库的组成部分。

目录

封装文化差异的多态facet集合
(类)
字符串与流转换
(C++11) (C++17 中弃用) (C++26 中移除)
在宽字符串与字节字符串之间执行转换
(类模板)
(C++11) (C++17 中弃用) (C++26 中移除)
在字节流缓冲区与宽字符流缓冲区之间执行转换
(类模板)
刻面类别基类
定义字符分类类别
(类)
定义字符转换错误
(类)
定义消息目录类型
(类)
定义日期格式常量
(类)
定义货币格式化模式
(类)
刻面类别
定义字符分类表
(类模板)
针对 std::ctype 类型 char 的特化版本
(类模板特化)
在字符编码之间进行转换,包括 UTF-8、UTF-16、UTF-32
(类模板)
定义字符串的字典序比较和哈希处理
(类模板)
实现从消息目录中检索字符串
(类模板)
从输入字符序列解析时间/日期值到 std::tm
(类模板)
格式化 std::tm 内容以输出为字符序列
(类模板)
从输入字符序列解析数值
(类模板)
将数值格式化为字符序列以进行输出
(类模板)
定义数值标点规则
(类模板)
解析并构造来自输入字符序列的货币值
(类模板)
将货币值格式化为字符序列以进行输出
(类模板)
定义由 std::money_get std::money_put 使用的货币格式化参数
(类模板)
区域设置特定的facet类别
表示系统提供的指定区域设置的 std::ctype
(类模板)
表示系统提供的 std::codecvt 用于指定区域设置
(类模板)
表示系统提供的 std::messages 针对指定区域设置
(类模板)
表示系统提供的 std::collate 用于指定区域设置
(类模板)
表示系统提供的 std::time_get 用于指定区域设置
(类模板)
表示系统提供的指定区域设置的 std::time_put 功能
(类模板)
表示系统提供的指定区域设置的 std::numpunct
(类模板)
表示系统提供的命名区域设置的 std::moneypunct
(类模板)

函数

区域设置与facet
从本地化环境中获取facet
(函数模板)
检查本地化环境是否实现特定facet
(函数模板)
字符分类
检查字符是否被本地化环境分类为空白字符
(函数模板)
检查字符是否被本地化环境分类为空白字符
(函数模板)
检查字符是否被本地化环境分类为控制字符
(函数模板)
检查字符是否被区域设置分类为大写字母
(函数模板)
检查字符是否被本地化环境分类为小写字母
(函数模板)
检查字符是否被本地化环境分类为字母字符
(函数模板)
检查字符是否被区域设置分类为数字
(函数模板)
检查字符是否被本地化环境分类为标点符号
(函数模板)
检查字符是否被本地化环境分类为十六进制数字
(函数模板)
检查字符是否被本地化环境分类为字母数字字符
(函数模板)
检查字符是否被区域设置分类为可打印字符
(函数模板)
检查字符是否被本地化环境分类为图形字符
(函数模板)
字符转换
使用 locale 的 ctype 平面将字符转换为大写形式
(函数模板)
使用 locale 的 ctype 刻面将字符转换为小写
(函数模板)

概要

namespace std {
    // locale:
    class locale;
    template <class Facet> const Facet& use_facet(const locale&);
    template <class Facet> bool has_facet(const locale&) 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> CharT toupper(CharT c, const locale& loc);
    template <class CharT> CharT tolower(CharT c, const locale& loc);
    template <class Codecvt, class Elem = wchar_t,
              class Wide_alloc = std::allocator<Elem>,
        class Byte_alloc = std::allocator<char>> class wstring_convert;
    template <class Codecvt, class Elem = wchar_t,
              class Tr = char_traits<Elem>> class wbuffer_convert;
    // ctype:
    class ctype_base;
    template <class CharT> class ctype;
    template <>            class ctype<char>; // 特化
    template <class CharT> class ctype_byname;
    class codecvt_base;
    template <class internT, class externT, class stateT> class codecvt;
    template <class internT, class externT, class stateT> class codecvt_byname;
    // numeric:
    template <class CharT, class InputIter = istreambuf_iterator<CharT>> class num_get;
    template <class CharT, class OutputIter = osterambuf_iterator<CharT>> class num_put;
    template <class CharT> class numpunct;
    template <class CharT> class numpunct_byname;
    // 排序规则:
    template <class CharT> class collate;
    template <class CharT> class collate_byname;
    // 日期和时间:
    class time_base;
    template <class CharT, class InputIter = istreambuf_iterator<CharT>>
        class time_get;
    template <class CharT, class InputIter> = istreambuf_iterator<CharT>>
        class time_get_byname;
    template <class CharT, class OutputIter> = ostreambuf_iterator<CharT>>
        class time_put;
    template <class CharT, class OutputIter> = ostreambuf_iterator<CharT>>
        class time_put_byname;
    // money:
    class money_base;
    template <class CharT, class InputIter = istreambuf_iterator<CharT>> >
        class money_get;
    template <class CharT, class OutputIter = ostreambuf_iterator<CharT>> >
        class money_put;
    template <class CharT, bool Intl = false> class moneypunct;
    template <class CharT, bool Intl = false> class moneypunct_byname;
    // 消息检索:
    class messages_base;
    template <class CharT> class messages;
    template <class CharT> class messages_byname;
}

std::locale

class locale
{
public:
    // 类型:
    class facet;
    class id;
    typedef int category;
    static const category // 此处赋值为示意性说明
        none     = 0,
        collate  = 0x010,
        ctype    = 0x020,
        monetary = 0x040,
        numeric  = 0x080,
        time     = 0x100,
        messages = 0x200,
        all = collate | ctype | monetary | numeric | time | messages;
    // 构造/复制/销毁:
    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();
    // 非虚函数
    const locale& operator=(const locale& other) noexcept;
    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;
    // 全局区域设置对象:
    static
    locale global(const locale&);
    static const locale& classic();
};

std::ctype_base

class ctype_base
{
public:
    typedef /*位掩码类型*/ mask;
    // 数值仅用于演示说明
    static const mask space = 1 << 0;
    static const mask print = 1 << 1;
    static const mask cntrl = 1 << 2;
    static const mask upper = 1 << 3;
    static const mask lower = 1 << 4;
    static const mask alpha = 1 << 5;
    static const mask digit = 1 << 6;
    static const mask punct = 1 << 7;
    static const mask xdigit= 1 << 8;
    static const mask blank = 1 << 9;
    static const mask alnum = alpha | digit;
    static const mask graph = alnum | punct;
};

std::ctype

template <class CharT>
class ctype : public locale::facet, public ctype_base
{
public:
    typedef CharT char_type;
    explicit ctype(size_t refs = 0);
    bool is(mask m, CharT c) const;
    const CharT* is(const CharT* low, const CharT* high, mask* vec) const;
    const CharT* scan_is(mask m,
                         const CharT* low, const CharT* high) const;
    const CharT* scan_not(mask m,
                          const CharT* low, const CharT* high) const;
    CharT        toupper(CharT c) const;
    const CharT* toupper(CharT* low, const CharT* high) const;
    CharT        tolower(CharT c) const;
    const CharT* tolower(CharT* low, const CharT* high) const;
    CharT        widen(char c) const;
    const char*  widen(const char* low, const char* high, CharT* to) const;
    char         narrow(CharT c, char dfault) const;
    const CharT* narrow(const CharT* low, const CharT*, char dfault,
                        char* to) const;
    static locale::id id;
protected:
    ~ctype();
    virtual bool do_is(mask m, CharT c) const;
    virtual const CharT* do_is(const CharT* low, const CharT* high,
                               mask* vec) const;
    virtual const CharT* do_scan_is(mask m,
                                    const CharT* low, const CharT* high) const;
    virtual const CharT* do_scan_not(mask m,
                                     const CharT* low, const CharT* high) const;
    virtual CharT do_toupper(CharT) const;
    virtual const CharT* do_toupper(CharT* low, const CharT* high) const;
    virtual CharT do_tolower(CharT) const;
    virtual const CharT* do_tolower(CharT* low, const CharT* high) const;
    virtual CharT do_widen(char) const;
    virtual const char*  do_widen(const char* low, const char* high,
                                  CharT* dest) const;
    virtual char do_narrow(CharT, char dfault) const;
    virtual const CharT* do_narrow(const CharT* low, const CharT* high,
                                   char dfault, char* dest) const;
};

std::ctype_byname

template <class CharT>
class ctype_byname : public ctype<CharT>
{
public:
    typedef typename ctype<CharT>::mask mask;
    explicit ctype_byname(const char*, size_t refs = 0);
    explicit ctype_byname(const string&, size_t refs = 0);
    protected:
    ~ctype_byname();
};

std:: ctype < char >

template <> class ctype<char>
    : public locale::facet, public ctype_base
{
public:
    typedef char char_type;
    explicit ctype(const mask* tab = 0, bool del = false,
                   size_t refs = 0);
    bool is(mask m, char c) const;
    const char* is(const char* low, const char* high, mask* vec) const;
    const char* scan_is (mask m,
                         const char* low, const char* high) const;
    const char* scan_not(mask m,
                         const char* low, const char* high) const;
    char        toupper(char c) const;
    const char* toupper(char* low, const char* high) const;
    char        tolower(char c) const;
    const char* tolower(char* low, const char* high) const;
    char        widen(char c) const;
    const char* widen(const char* low, const char* high, char* to) const;
    char        narrow(char c, char dfault) const;
    const char* narrow(const char* low, const char* high, char dfault,
                       char* to) const;
    static locale::id id;
    static const size_t table_size = /* 实现定义 */;
    const mask* table() const noexcept;
    static const mask* classic_table() noexcept;
protected:
    ~ctype();
    virtual char        do_toupper(char c) const;
    virtual const char* do_toupper(char* low, const char* high) const;
    virtual char        do_tolower(char c) const;
    virtual const char* do_tolower(char* low, const char* high) const;
    virtual char        do_widen(char c) const;
    virtual const char* do_widen(const char* low,
                                 const char* high,
                                 char* to) const;
    virtual char        do_narrow(char c, char dfault) const;
    virtual const char* do_narrow(const char* low,
                                  const char* high,
                                  char dfault, char* to) const;
};

std::codecvt_base

class codecvt_base
{
public:
    enum result { ok, partial, error, noconv };
};

std::codecvt

template <class internT, class externT, class stateT>
class codecvt : public locale::facet, public codecvt_base
{
public:
    typedef internT intern_type;
    typedef externT extern_type;
    typedef stateT state_type;
    explicit codecvt(size_t refs = 0);
    result out(stateT& state,
               const internT* from, const internT* from_end,
               const internT*& from_next,
               externT* to, externT* to_end, externT*& to_next) const;
    result unshift(stateT& state, externT* to,
                   externT* to_end, externT*& to_next) const;
    result in(stateT& state,
              const externT* from, const externT* from_end,
              const externT*& from_next,
              internT* to,
              internT* to_end, internT*& to_next) const;
    int encoding() const noexcept;
    bool always_noconv() const noexcept;
    int length(stateT&, const externT* from, const externT* end,
               size_t max) const;
    int max_length() const noexcept;
    static locale::id id;
protected:
    ~codecvt();
    virtual result do_out(stateT& state,
                          const internT* from, const internT* from_end,
                          const internT*& from_next,
                          externT* to,
                          externT* to_end, externT*& to_next) const;
    virtual result do_in(stateT& state,
                         const externT* from, const externT* from_end,
                         const externT*& from_next,
                         internT* to,
                         internT* to_end, internT*& to_next) const;
    virtual result do_unshift(stateT& state,
                              externT* to,
                              externT* to_end, externT*& to_next) const;
    virtual int do_encoding() const noexcept;
    virtual bool do_always_noconv() const noexcept;
    virtual int do_length(stateT&, const externT* from,
                          const externT* end, size_t max) const;
    virtual int do_max_length() const noexcept;
};

std::codecvt_byname

template <class internT, class externT, class stateT>
class codecvt_byname : public codecvt<internT, externT, stateT>
{
public:
    explicit codecvt_byname(const char*, size_t refs = 0);
    explicit codecvt_byname(const string&, size_t refs = 0);
protected:
    ~codecvt_byname();
};

std::num_get

template <class CharT, class InputIter = istreambuf_iterator<CharT>>
class num_get : public locale::facet
{
public:
    typedef CharT           字符类型;
    typedef InputIter   迭代器类型;
    explicit num_get(size_t 引用计数 = 0);
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, bool&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, long&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, long long&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, unsigned short&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, unsigned int&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, unsigned long&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, unsigned long long&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, float&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, double&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, long double&) const;
    迭代器类型 get(迭代器类型 输入, 迭代器类型 结束, ios_base&,
                  ios_base::iostate& 错误状态, void*&) const;
    static locale::id id;
protected:
    ~num_get();
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, bool&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, long&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, long long&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, unsigned short&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, unsigned int&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, unsigned long&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, unsigned long long&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, float&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, double&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, long double&) const;
    virtual 迭代器类型 do_get(迭代器类型, 迭代器类型, ios_base&,
                             ios_base::iostate& 错误状态, void*&) const;
};

std::num_put

template <class CharT, class OutputIter = ostreambuf_iterator<CharT>>
class num_put : public locale::facet
{
public:
    typedef CharT char_type;
    typedef OutputIter iter_type;
    explicit num_put(size_t refs = 0);
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  bool v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  long v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  long long v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  unsigned long v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  unsigned long long v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  double v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  long double v) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  const void* v) const;
    static locale::id id;
protected:
    ~num_put();
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             bool v) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             long v) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             long long v) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             unsigned long) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             unsigned long long) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             double v) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             long double v) const;
    virtual iter_type do_put(iter_type, ios_base&, char_type fill,
                             const void* v) const;
};

std::numpunct

template <class CharT>
class numpunct : public locale::facet
{
public:
    typedef CharT char_type;
    typedef basic_string<CharT> string_type;
    explicit numpunct(size_t refs = 0);
    char_type   decimal_point() const;
    char_type   thousands_sep() const;
    string      grouping()      const;
    string_type truename()      const;
    string_type falsename()     const;
    static locale::id id;
protected:
    ~numpunct(); // 虚函数
    virtual char_type   do_decimal_point() const;
    virtual char_type   do_thousands_sep() const;
    virtual string      do_grouping()      const;
    virtual string_type do_truename()      const; // 用于布尔类型
    virtual string_type do_falsename()     const; // 用于布尔类型
};

std::numpunct_byname

template <class CharT>
class numpunct_byname : public numpunct<CharT>
{
public:
    typedef CharT char_type;
    typedef basic_string<CharT> string_type;
    explicit numpunct_byname(const char*, size_t refs = 0);
    explicit numpunct_byname(const string&, size_t refs = 0);
protected:
    ~numpunct_byname();
};

std::collate

template <class CharT>
class collate : public locale::facet
{
public:
    typedef CharT char_type;
    typedef basic_string<CharT> string_type;
    explicit collate(size_t refs = 0);
    int compare(const CharT* low1, const CharT* high1,
                const CharT* low2, const CharT* high2) const;
    string_type transform(const CharT* low, const CharT* high) const;
    long hash(const CharT* low, const CharT* high) const;
    static locale::id id;
protected:
    ~collate();
    virtual int do_compare(const CharT* low1, const CharT* high1,
                           const CharT* low2, const CharT* high2) const;
    virtual string_type do_transform(const CharT* low,
                                     const CharT* high) const;
    virtual long do_hash (const CharT* low, const CharT* high) const;
};

std::collate_byname

template <class CharT>
class collate_byname : public collate<CharT>
{
public:
    typedef basic_string<CharT> string_type;
    explicit collate_byname(const char*, size_t refs = 0);
    explicit collate_byname(const string&, size_t refs = 0);
protected:
    ~collate_byname();
};

std::time_base

class time_base
{
public:
    enum dateorder { no_order, dmy, mdy, ymd, ydm };
};

std::time_get

template <class CharT, class InputIter = istreambuf_iterator<CharT>>
class time_get : public locale::facet, public time_base
{
public:
    typedef CharT char_type;
    typedef InputIter iter_type;
    explicit time_get(size_t refs = 0);
    dateorder date_order() const;
    iter_type get_time(iter_type s, iter_type end, ios_base& f,
                       ios_base::iostate& err, tm* t) const;
    iter_type get_date(iter_type s, iter_type end, ios_base& f,
                       ios_base::iostate& err, tm* t) const;
    iter_type get_weekday(iter_type s, iter_type end, ios_base& f,
                          ios_base::iostate& err, tm* t) const;
    iter_type get_monthname(iter_type s, iter_type end, ios_base& f,
                            ios_base::iostate& err, tm* t) const;
    iter_type get_year(iter_type s, iter_type end, ios_base& f,
                       ios_base::iostate& err, tm* t) const;
    iter_type get(iter_type s, iter_type end, ios_base& f,
                  ios_base::iostate& err, tm* t, char format,
                  char modifier = 0) const;
    iter_type get(iter_type s, iter_type end, ios_base& f,
                  ios_base::iostate& err, tm* t,
                  const char_type* fmt, const char_type* fmtend) const;
    static locale::id id;
protected:
    ~time_get();
    virtual dateorder do_date_order() const;
    virtual iter_type do_get_time(iter_type s, iter_type end, ios_base&,
                                  ios_base::iostate& err, tm* t) const;
    virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&,
                                  ios_base::iostate& err, tm* t) const;
    virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&,
                                     ios_base::iostate& err, tm* t) const;
    virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&,
                                       ios_base::iostate& err, tm* t) const;
    virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&,
                                  ios_base::iostate& err, tm* t) const;
    virtual iter_type do_get(iter_type s, iter_type end, ios_base& f,
                             ios_base::iostate& err, tm* t,
                             char format, char modifier) const;
};

std::time_get_byname

template <class CharT, class InputIter = istreambuf_iterator<CharT>>
class time_get_byname : public time_get<CharT, InputIter>
{
public:
    typedef time_base::dateorder dateorder;
    typedef InputIter iter_type;
    explicit time_get_byname(const char*, size_t refs = 0);
    explicit time_get_byname(const string&, size_t refs = 0);
protected:
    ~time_get_byname();
};

std::time_put

template <class CharT, class OutputIter = ostreambuf_iterator<CharT>>
class time_put : public locale::facet
{
public:
    typedef CharT char_type;
    typedef OutputIter iter_type;
    explicit time_put(size_t refs = 0);
    // 以下成员函数通过其他成员函数实现
    iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb,
                  const CharT* pattern, const CharT* pat_end) const;
    iter_type put(iter_type s, ios_base& f, char_type fill,
                  const tm* tmb, char format, char modifier = 0) const;
    static locale::id id;
protected:
    ~time_put();
    virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t,
                             char format, char modifier) const;
};

std::time_put_byname

template <class CharT, class OutputIter = ostreambuf_iterator<CharT>>
class time_put_byname : public time_put<CharT, OutputIter>
{
public:
    typedef CharT char_type;
    typedef OutputIter iter_type;
    explicit time_put_byname(const char*, size_t refs = 0);
    explicit time_put_byname(const string&, size_t refs = 0);
protected:
    ~time_put_byname();
};

std::money_get

template <class CharT, class InputIter = istreambuf_iterator<CharT>>
class money_get : public locale::facet
{
public:
    typedef CharT char_type;
    typedef InputIter iter_type;
    typedef basic_string<CharT> string_type;
    explicit money_get(size_t refs = 0);
    iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
                  ios_base::iostate& err, long double& units) const;
    iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
                  ios_base::iostate& err, string_type& digits) const;
    static locale::id id;
protected:
    ~money_get();
    virtual iter_type do_get(iter_type, iter_type, bool, ios_base&,
                             ios_base::iostate& err,
                             long double& units) const;
    virtual iter_type do_get(iter_type, iter_type, bool, ios_base&,
                             ios_base::iostate& err,
                             string_type& digits) const;
};

std::money_put

template <class CharT, class OutputIter = ostreambuf_iterator<CharT>>
class money_put : public locale::facet
{
public:
    typedef CharT char_type;
    typedef OutputIter iter_type;
    typedef basic_string<CharT> string_type;
    explicit money_put(size_t refs = 0);
    iter_type put(iter_type s, bool intl, ios_base& f,
                  char_type fill, long double units) const;
    iter_type put(iter_type s, bool intl, ios_base& f,
                  char_type fill, const string_type& digits) const;
    static locale::id id;
protected:
    ~money_put();
    virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill,
                             long double units) const;
    virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill,
                             const string_type& digits) const;
};

std::money_base

class money_base
{
public:
    enum part { none, space, symbol, sign, value };
    struct pattern { char field[4]; };
};

std::moneypunct

template <class CharT, bool International = false>
class moneypunct : public locale::facet, public money_base
{
public:
    typedef CharT char_type;
    typedef basic_string<CharT> string_type;
    explicit moneypunct(size_t refs = 0);
    CharT       小数位点() const;
    CharT       千位分隔符() const;
    string      分组规则()      const;
    string_type 货币符号()   const;
    string_type 正号() const;
    string_type 负号() const;
    int         小数位数()   const;
    pattern     正数格式()    const;
    pattern     负数格式()    const;
    static locale::id id;
    static const bool intl = International;
protected:
    ~moneypunct();
    virtual CharT       实际小数位点() const;
    virtual CharT       实际千位分隔符() const;
    virtual string      实际分组规则()      const;
    virtual string_type 实际货币符号()   const;
    virtual string_type 实际正号() const;
    virtual string_type 实际负号() const;
    virtual int         实际小数位数()   const;
    virtual pattern     实际正数格式()    const;
    virtual pattern     实际负数格式()    const;
};

std::moneypunct_byname

template <class CharT, bool Intl = false>
class moneypunct_byname : public moneypunct<CharT, Intl>
{
public:
    typedef money_base::pattern pattern;
    typedef basic_string<CharT> string_type;
    explicit moneypunct_byname(const char*, size_t refs = 0);
    explicit moneypunct_byname(const string&, size_t refs = 0);
protected:
    ~moneypunct_byname();
};

std::messages_base

class messages_base
{
public:
    typedef /* 未指定的有符号整数类型 */ catalog;
};

std::messages

template <class CharT>
class messages : public locale::facet, public messages_base {
public:
    typedef CharT char_type;
    typedef basic_string<CharT> string_type;
    explicit messages(size_t refs = 0);
    catalog open(const basic_string<char>& fn, const locale&) const;
    string_type get(catalog c, int set, int msgid,
                    const string_type& dfault) const;
    void close(catalog c) const;
    static locale::id id;
protected:
    ~messages();
    virtual catalog do_open(const basic_string<char>&, const locale&) const;
    virtual string_type do_get(catalog, int set, int msgid,
                               const string_type& dfault) const;
    virtual void do_close(catalog) const;
};

std::messages_byname

template <class CharT>
class messages_byname : public messages<CharT>
{
public:
    typedef messages_base::catalog catalog;
    typedef basic_string<CharT> string_type;
    explicit messages_byname(const char*, size_t refs = 0);
    explicit messages_byname(const string&, size_t refs = 0);
protected:
    ~messages_byname();
};

std::wstring_convert

template<class Codecvt, class Elem = wchar_t,
    class Wide_alloc = std::allocator<Elem>,
    class Byte_alloc = std::allocator<char>>
class wstring_convert
{
public:
    typedef std::basic_string<char, char_traits<char>, Byte_alloc> byte_string;
    typedef std::basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
    typedef typename Codecvt::state_type state_type;
    typedef typename wide_string::traits_type::int_type int_type;
    explicit wstring_convert(Codecvt* pcvt = new Codecvt);
    wstring_convert(Codecvt* pcvt, state_type state);
    explicit wstring_convert(const byte_string& byte_err,
                             const wide_string& wide_err = wide_string());
    ~wstring_convert();
    wstring_convert(const wstring_convert&) = delete;
    wstring_convert& operator=(const wstring_convert&) = delete;
    wide_string from_bytes(char byte);
    wide_string from_bytes(const char* ptr);
    wide_string from_bytes(const byte_string& str);
    wide_string from_bytes(const char* first, const char* last);
    byte_string to_bytes(Elem wchar);
    byte_string to_bytes(const Elem* wptr);
    byte_string to_bytes(const wide_string& wstr);
    byte_string to_bytes(const Elem* first, const Elem* last);
    size_t converted() const noexcept;
    state_type state() const;
private:
    byte_string byte_err_string; // 仅用于说明
    wide_string wide_err_string; // 仅用于说明
    Codecvt* cvtptr;             // 仅用于说明
    state_type cvtstate;         // 仅用于说明
    size_t cvtcount;             // 仅用于说明
};

std::wbuffer_convert

template<class Codecvt,
    class Elem = wchar_t,
    class Tr = std::char_traits<Elem>>
class wbuffer_convert : public std::basic_streambuf<Elem, Tr>
{
public:
    typedef typename Codecvt::state_type state_type;
    explicit wbuffer_convert(std::streambuf* bytebuf = 0,
                             Codecvt* pcvt = new Codecvt,
                             state_type state = state_type());
    ~wbuffer_convert();
    wbuffer_convert(const wbuffer_convert&) = delete;
    wbuffer_convert& operator=(const wbuffer_convert&) = delete;
    std::streambuf* rdbuf() const;
    std::streambuf* rdbuf(std::streambuf* bytebuf);
    state_type state() const;
private:
    std::streambuf* bufptr; // 仅用于说明
    Codecvt* cvtptr;        // 仅用于说明
    state_type cvtstate;    // 仅用于说明
};

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

DR 适用版本 发布时的行为 正确行为
LWG 71 C++98 time_get::do_get_monthname 的参数 end 在概要中缺失 已添加
LWG 75 C++98 codecvt codecvt_byname 的成员函数 length do_length 的参数 state 类型在概要中为 const stateT & 修正为 stateT &
LWG 124 C++98 codecvt_byname 的成员函数 do_scan_is do_scan_not 的返回类型在概要中为 const char * 修正为
const charT *
LWG 228 C++98 所有 XXX_byname 刻面的虚成员函数都在概要中列出 仅列出析构函数
(移除了所有其他
虚成员函数)
LWG 268 C++98 std::locale 的默认构造函数和拷贝构造函数声明后的分号在概要中缺失 已添加
LWG 1298 C++98 概要中存在显式特化
ctype_byname < char >
已移除