首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

falsename

Defined in header <locale>

public: string_type truename() const;

(1)

public: string_type falsename() const;

(2)

protected: virtual string_type do_truename() const;

(3)

protected: virtual string_type do_falsename() const;

(4)

1-2%29公共成员函数,调用成员函数do_truenamedo_falsename派生最多的类。

3%29返回用作布尔值表示的字符串。true...

4%29返回用作布尔值表示的字符串。false...

返回值

1,3%29类型的对象string_type用作true.标准专业std::numpunct回归"true"L"true"...

2、4%29类型的对象string_type用作false.标准专业std::numpunct回归"false"L"false"...

二次

代码语言:javascript
复制
#include <iostream>
#include <locale>
#include <iomanip>
 
struct custom_tf : std::numpunct<char> {
    std::string do_truename()  const { return "t"; }
    std::string do_falsename() const { return "f"; }
};
 
int main()
{
    std::cout << std::boolalpha;
    std::cout << "default locale: " << true << true << false << false << '\n';
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_tf));
    std::cout << "locale with modified numpunct: " 
              << true << true << false << false << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
default locale: truetruefalsefalse
locale with modified numpunct: ttff

二次

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券