money_put::put


public member function
iter_type put (iter_type s, bool intl, ios_base& str,
               char_type fill, long double units) const;
iter_type put (iter_type s, bool intl, ios_base& str,
               char_type fill, const string_type& digits) const;

Format monetary expression

Formats either units or digits into s as a sequence of characters expressing a monetary amount. For the process, it uses moneypunct<charT,intl> (where intl is the third parameter of this function) and fill as fill character, as well as the formatting options selected in the object passed as str.

The function writes the characters resulting from the formatting operation into the sequence whose first character location is pointed by s.

An iterator to the character right after the last element written to the output sequence is returned by the function.

During its operation, the version of this function in the generic template simply calls the virtual protected member do_put, which is the member function in charge of performing the actions described above.

Parameters

s
Iterator pointing to the first character of the output sequence.
The sequence shall be large enough to contain the whole expression.
iter_type is a member alias of the second template parameter of money_put (i.e., the facet's iterator type). This can be any output iterator. By default, this is an ostreambuf_iterator, allowing implicit conversions from ostream objects such as cout.
intl
Value to be used as the international representation template argument for the corresponding moneypunct class template.
str
Object of a class derived from ios_base (generally an output stream object). It is only used to obtain formatting information.
fill
Fill character. The fill character is used in output insertion operations to fill spaces when results have to be padded to the field width.
char_type is a member alias of the first template parameter of money_put (i.e., the facet's character type).

[/dd]
units
Floating-point value to be formatted as a monetary expression.
digits
string object with the individual digits to be formatted (only digits, no punctuation marks).


Return value

The next character in the sequence right after the last one written.
iter_type is a member alias of money_put's second template parameter (i.e., the facet's iterator type).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// money_put example
#include <iostream>
#include <locale>
using namespace std;

int main ()
{

  const money_put<char>& monput = use_facet<money_put<char> >(cout.getloc());

  monput.put (cout, false, cout, ' ', 12.95);
  cout << endl;

  monput.put (cout, false, cout, ' ', "1295");
  cout << endl;

  return 0;
} 


Possible output:

13
1295


See also