Mark Ransom
Mark Ransom

Reputation: 308402

How to get a facet from a std::locale object?

I want to get the numpunct<char> facet for the native locale. I can generate a native locale object by constructing an object with an empty string std::locale native_loc(""), but once I have it how do I get a numpunct from it? The documentation I've found doesn't really show the connection between the two.

Upvotes: 8

Views: 1092

Answers (1)

Johannes Schaub - litb
Johannes Schaub - litb

Reputation: 507105

Use use_facet<facet_type>(locale):

std::numpunct<char> const&n = std::use_facet< std::numpunct<char> >(std::locale(""));

Upvotes: 8

Related Questions