c++ - For locale-sensitive functions, is it more common to pass the std::locale or the needed facet object(s)? -


recently wrote family of functions trimming leading , trailing whitespace off of input string. concept of "whitespace" locale-dependent, realized need either pass in const std::ctype<char_t> reference or const std::locale reference , call std::use_facet<std::ctype<char_t> > on const std::locale object.

in library, decided upon passing const std::locale reference because figured std::locale object encapsulated entirety of locale information, , std::use_facet library-specific mechanism of access. however, started wondering whether might better choice (perhaps more common?) pass in const std::ctype<char_t> reference direct use functions.

which more common in locale-sensitive libraries: passing const std::locale reference or const-references needed facets?

seeing how standard library's isspace() std::isspace(chart, const std::locale&), think follow principle of least surprise if trim whitespace functions took const locale&.

but what's stopping allowing both?


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -