std::numpunct<CharT>:: thousands_sep, do_thousands_sep
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::thousands_sep
numpunct::do_thousands_sep
|
||||
|
헤더 파일에 정의됨
<locale>
|
||
|
public
:
char_type thousands_sep ( ) const ; |
(1) | |
|
protected
:
virtual char_type do_thousands_sep ( ) const ; |
(2) | |
1)
Public 멤버 함수, 가장 파생된 클래스의 멤버 함수
do_thousands_sep
를 호출합니다.
2)
정수 및 부동 소수점 값의 정수 부분을 파싱하거나 포맷팅할 때 숫자 그룹 사이의 구분자로 사용될 문자를 반환합니다.
목차 |
반환값
천 단위 구분자로 사용할
char_type
타입의 객체.
std::numpunct
의 표준 특수화는
','
와
L
','
를 반환합니다.
예제
이 코드 실행
#include <iostream> #include <locale> struct space_out : std::numpunct<char> { char do_thousands_sep() const { return ' '; } // 공백으로 구분 std::string do_grouping() const { return "\1"; } // 1자리 숫자 그룹 }; int main() { std::cout << "default locale: " << 12345678 << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new space_out)); std::cout << "locale with modified numpunct: " << 12345678 << '\n'; }
출력:
default locale: 12345678 locale with modified numpunct: 1 2 3 4 5 6 7 8
결함 보고서
다음 동작 변경 결함 보고서는 이전에 발표된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 20 | C++98 |
반환 타입이
string_type
이었음
|
char_type
으로 변경됨
|
참고 항목
|
[virtual]
|
천 단위 구분자 사이의 숫자 자릿수들을 제공합니다
(가상 protected 멤버 함수) |