Namespaces
Variants

std:: moneypunct_byname

From cppreference.net
헤더에 정의됨 <locale>
template < class CharT, bool Intl = false >
class moneypunct_byname : public std:: moneypunct < CharT, Intl > ;

std::moneypunct_byname 는 생성 시 지정된 로캘의 통화 형식 기본 설정을 캡슐화하는 std::moneypunct 패싯입니다.

목차

특수화

표준 라이브러리는 다음 타입 요구사항을 만족하는 모든 특수화를 제공함이 보장됩니다:

  • CharT char wchar_t 중 하나이며,
  • Intl bool 매개변수에 대한 가능한 특수화입니다.

중첩 타입

유형 정의
pattern std::money_base::pattern
string_type std:: basic_string < CharT >

멤버 함수

(constructor)
새로운 moneypunct_byname 패싯을 생성합니다
(public member function)
(destructor)
moneypunct_byname 패싯을 파괴합니다
(protected member function)

std::moneypunct_byname:: moneypunct_byname

explicit moneypunct_byname ( const char * name, std:: size_t refs = 0 ) ;
explicit moneypunct_byname ( const std:: string & name, std:: size_t refs = 0 ) ;
(C++11부터)

지정된 로캘 이름 name 에 대한 새로운 std::moneypunct_byname 패싯을 생성합니다.

refs 는 리소스 관리에 사용됩니다: refs == 0 인 경우, 구현은 이 패싯을 포함하는 마지막 std::locale 객체가 소멸될 때 패싯을 파괴합니다. 그렇지 않으면 객체는 파괴되지 않습니다.

매개변수

name - 로캘의 이름
refs - 패싯에 연결되는 참조 횟수

std::moneypunct_byname:: ~moneypunct_byname

protected :
~moneypunct_byname ( ) ;

페이셋을 파괴합니다.

std:: moneypunct 에서 상속됨

중첩 타입

유형 정의
char_type CharT
string_type std:: basic_string < CharT >

데이터 멤버

멤버 설명
std::locale::id id [static] 패싯 의 식별자
const bool intl [static] International

멤버 함수

do_decimal_point 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)
do_thousands_sep 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)
do_grouping 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)
do_curr_symbol 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)
do_positive_sign 또는 do_negative_sign 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)
do_frac_digits 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)
do_pos_format / do_neg_format 를 호출합니다
( std::moneypunct<CharT,International> 의 public 멤버 함수)

보호된 멤버 함수

소수점으로 사용할 문자를 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)
천 단위 구분자로 사용할 문자를 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)
[virtual]
천 단위 구분자 사이의 자릿수들을 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)
통화 식별자로 사용할 문자열을 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)
양수 또는 음수 값을 나타내는 문자열을 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)
소수점 이후 표시할 자릿수를 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)
통화 값에 대한 서식 패턴을 제공함
( std::moneypunct<CharT,International> 의 virtual protected 멤버 함수)

std:: money_base 로부터 상속됨

중첩 타입

타입 정의
enum part { none, space, symbol, sign, value } ; 범위 없는 열거형 타입
struct pattern { char field [ 4 ] ; } ; 통화 형식 타입
열거형 상수 설명
none 마지막 위치를 제외하고 공백이 허용되지만 필수는 아님 (마지막 위치에서는 공백이 허용되지 않음)
space 하나 이상의 공백 문자가 필요함
symbol std::moneypunct::curr_symbol 이 반환하는 문자 시퀀스가 필요함
sign std::moneypunct::positive_sign 또는 std::moneypunct::negative_sign 이 반환하는 첫 번째 문자가 필요함
value 절대 숫자 통화 값이 필요함

예제

이 예제는 나머지 로케일을 변경하지 않고 다른 언어의 통화 서식 규칙을 적용하는 방법을 보여줍니다.

#include <iomanip>
#include <iostream>
#include <locale>
int main()
{
    long double mon = 1234567;
    std::locale::global(std::locale("en_US.utf8"));
    std::wcout.imbue(std::locale());
    std::wcout << L"american locale: " << std::showbase
               << std::put_money(mon) << '\n';
    std::wcout.imbue(std::locale(std::wcout.getloc(),
                                 new std::moneypunct_byname<wchar_t>("ru_RU.utf8")));
    std::wcout << L"american locale with russian moneypunct: "
               << std::put_money(mon) << '\n';
}

출력:

american locale: $12,345.67
american locale with russian moneypunct: 12 345.67 руб

참고 항목

std::money_get std::money_put 에서 사용되는 통화 서식 매개변수를 정의합니다
(클래스 템플릿)