Namespaces
Variants

std::moneypunct<CharT,International>:: grouping, do_grouping

From cppreference.net
헤더에 정의됨 <locale>
public :
std:: string grouping ( ) const ;
(1)
protected :
virtual std:: string do_grouping ( ) const ;
(2)
1) Public 멤버 함수, 가장 파생된 클래스의 do_grouping 멤버 함수를 호출합니다.
2) 통화 출력에서 숫자의 그룹화를 결정하는 패턴을 반환하며, 이는 std::numpunct::do_grouping 과 정확히 동일한 의미를 가집니다.

반환값

그룹을 담고 있는 std::string 타입의 객체입니다. std::moneypunct 의 표준 특수화는 빈 문자열을 반환하여 그룹화가 없음을 나타냅니다. 일반적인 그룹화(예: en_US 로케일)는 " \003 " 을 반환합니다.

예제

#include <iomanip>
#include <iostream>
#include <iterator>
#include <locale>
struct space_out : std::moneypunct<char>
{
    pattern do_pos_format() const { return {value, none, none, none}; }
    int do_frac_digits() const { return 0; }
    char_type do_thousands_sep() const { return ' '; }
    string_type do_grouping() const { return "\002"; }
};
int main()
{
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << "american locale: " << std::showbase
              << std::put_money(12345678.0) << '\n';
    std::cout.imbue(std::locale(std::cout.getloc(), new space_out));
    std::cout << "locale with modified moneypunct: "
              << std::put_money(12345678.0) << '\n';
}

출력:

american locale: $123,456.78
locale with modified moneypunct: 12 34 56 78

참고 항목

천 단위 구분자로 사용할 문자를 제공함
(가상 protected 멤버 함수)
소수점으로 사용할 문자를 제공함
(가상 protected 멤버 함수)