std::numpunct<CharT>:: decimal_point, do_decimal_point
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::decimal_point
numpunct::do_decimal_point
|
||||
|
헤더 파일에 정의됨
<locale>
|
||
|
public
:
char_type decimal_point ( ) const ; |
(1) | |
|
protected
:
virtual char_type do_decimal_point ( ) const ; |
(2) | |
1)
Public 멤버 함수, 가장 파생된 클래스의
do_decimal_point
멤버 함수를 호출합니다.
2)
정수 부분과 소수 부분 사이에 사용될 소수점 구분 문자를 반환합니다.
반환값
소수점 구분자로 사용할
char_type
타입의 값입니다.
std::numpunct
의 표준 특수화는
'.'
와
L
'.'
를 반환합니다.
예제
이 코드 실행
#include <iostream> #include <locale> struct slash : std::numpunct<char> { char do_decimal_point() const { return '/'; } // 슬래시로 구분 }; int main() { std::cout.precision(10); std::cout << "default locale: " << 1234.5678 << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new slash)); std::cout << "locale with modified numpunct: " << 1234.5678 << '\n'; }
출력:
default locale: 1234.5678 locale with modified numpunct: 1234/5678