std::numpunct<CharT>:: truename, do_truename, falsename, do_falsename
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::numpunct
| Member functions | ||||
|
numpunct::truename
numpunct::do_truename
numpunct::falsename
numpunct::do_falsename
|
|
헤더 파일에 정의됨
<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)
공개 멤버 함수로, 가장 파생된 클래스의 멤버 함수
do_truename
와
do_falsename
을 각각 호출합니다.
3)
불리언 값
true
의 표현으로 사용될 문자열을 반환합니다.
4)
불리언 값
false
의 표현으로 사용될 문자열을 반환합니다.
반환값
1,3)
string_type
타입의 객체로,
true
의 표현에 사용됩니다.
std::numpunct
의 표준 특수화는
"true"
와
L
"true"
를 반환합니다.
2,4)
string_type
타입의 객체로
false
의 표현에 사용됩니다.
std::numpunct
의 표준 특수화들은
"false"
와
L
"false"
를 반환합니다.
예제
이 코드 실행
#include <iomanip> #include <iostream> #include <locale> 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; // 기본 boolalpha 출력 std::cout << "기본 로케일,\n" " boolalpha true: " << true << "\n" " boolalpha false: " << false << "\n\n"; // custom_tf가 적용된 로케일 std::cout.imbue(std::locale(std::cout.getloc(), new custom_tf)); std::cout << "수정된 numpunct가 적용된 로케일,\n" " boolalpha true: " << true << "\n" " boolalpha false: " << false << '\n'; }
출력:
기본 로케일, boolalpha true: true boolalpha false: false 수정된 numpunct가 적용된 로케일, boolalpha true: t boolalpha false: f