GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::moneypunct::positive_sign,do_positive_sign,negative_sign,(3) C++ Standard Libary std::moneypunct::positive_sign,do_positive_sign,negative_sign,(3)

std::moneypunct::positive_sign,do_positive_sign,negative_sign, - std::moneypunct::positive_sign,do_positive_sign,negative_sign,


Defined in header <locale>
public: (1)
string_type positive_sign() const;
public: (2)
string_type negative_sign() const;
protected: (3)
virtual string_type do_positive_sign() const;
protected: (4)
virtual string_type do_negative_sign() const;


1) Public member function, calls the member function do_positive_sign of the most
derived class.
2) Public member function, calls the member function do_negative_sign of the most
derived class.
3) Returns the string that is used for formatting of positive monetary values.
3) Returns the string that is used for formatting of negative monetary values.


Only the first character of the string returned is the character that appears in the
pos_format()/neg_format() position indicated by the value sign. The rest of the
characters appear after the rest of the monetary string.


In particular, for negative_sign of "-", the formatting may appear as "-1.23 €",
while for negative_sign of "()" it would appear as "(1.23 €)".


The string of type string_type holding the characters to be used as positive or
negative sign.

// Run this code


#include <iostream>
#include <iomanip>
#include <locale>


struct my_punct : std::moneypunct_byname<char, false> {
my_punct(const char* name) : moneypunct_byname(name) {}
string_type do_negative_sign() const { return "()"; }
};


int main()
{
std::locale loc("de_DE.utf8");
std::cout.imbue(loc);
std::cout << loc.name() << " negative sign is '"
<< std::use_facet<std::moneypunct<char>>(loc).negative_sign()
<< "' for example: " << std::showbase << std::put_money(-1234) << '\n';


std::locale loc2("ms_MY.utf8");
std::cout.imbue(loc2);
std::cout << loc2.name() << " negative sign is '"
<< std::use_facet<std::moneypunct<char>>(loc2).negative_sign()
<< "' for example: " << std::put_money(-1234) << '\n';


std::cout.imbue(std::locale(std::cout.getloc(), new my_punct("de_DE.utf8")));
std::cout << "de_DE.utf8 with negative_sign set to \"()\": "
<< std::put_money(-1234) << '\n';


}


de_DE.utf8 negative sign is '-' for example: -12,34 €
ms_MY.utf8 negative sign is '()' for example: (RM12.34)
de_DE.utf8 with negative_sign set to "()": (12,34 €)


do_pos_format provides the formatting pattern for currency values
do_neg_format (virtual protected member function)
[virtual]

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.