Effects: The classes
num_get<>
and
num_put<>
handle locale-dependent numeric formatting and
parsing
. These inserter functions use the imbued
locale
value to perform numeric formatting
. When val
is of type
bool,
long,
unsigned long,
long long, unsigned long long,
double,
long double,
or
const void*,
the formatting conversion occurs as if it performed the following code fragment:
bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
getloc()).put(*this, *this, fill(), val).failed();
When val is of type
short
the formatting conversion occurs as if it performed the following code fragment:
ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
getloc()).put(*this, *this, fill(),
baseflags == ios_base::oct || baseflags == ios_base::hex
? static_cast<long>(static_cast<unsigned short>(val))
: static_cast<long>(val)).failed();
When val is of type
int
the formatting conversion occurs as if it performed the following code fragment:
ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
getloc()).put(*this, *this, fill(),
baseflags == ios_base::oct || baseflags == ios_base::hex
? static_cast<long>(static_cast<unsigned int>(val))
: static_cast<long>(val)).failed();
When val is of type
unsigned short
or
unsigned int
the formatting conversion occurs as if it performed the following code fragment:
bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
getloc()).put(*this, *this, fill(), static_cast<unsigned long>(val)).failed();
When val is of type
float
the formatting conversion occurs as if it performed the following code fragment:
bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>(
getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();