Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::use_facet(3)	      C++ Standard Libary	     std::use_facet(3)

NAME
       std::use_facet -	std::use_facet

Synopsis
	  Defined in header <locale>
	  template< class Facet	>
	  const	Facet& use_facet( const	std::locale& loc );

	  Obtains a reference to a facet implemented by	loc.

Parameters
	  loc -	the locale object to query

Return value
	  Returns  a  reference	 to  the facet.	The reference returned by this
       function	is valid
	  as long as any std::locale object exists that	implements Facet.

Exceptions
	  std::bad_cast	if std::has_facet<Facet>(loc) == false.

Example
	  Display the 3-letter currency	name used by the user's	preferred  lo-
       cale

       // Run this code

	#include <iostream>
	#include <locale>

	int main()
	{
	    std::locale	loc = std::locale(""); // user's preferred locale
	    std::cout << "Your currency	string is "
		      <<		  std::use_facet<std::moneypunct<char,
       true>>(loc).curr_symbol() << '\n';
	}

Output:
	Your currency string is	USD

See also
	  locale    set	of polymorphic facets that encapsulate	cultural  dif-
       ferences
		    (class)
	  has_facet checks if a	locale implements a specific facet
		    (function template)

http://cppreference.com		  2022.07.31		     std::use_facet(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::use_facet&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help