std::use_facet
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <locale>
|
||
| template< class Facet > const Facet& use_facet( const std::locale& loc ); |
||
Получает ссылку на грани осуществляться
loc. Original:
Obtains a reference to a facet implemented by
loc. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
[править] Параметры
| loc | - | локализации объекта для запроса
Original: the locale object to query The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[править] Возвращаемое значение
Возвращает ссылку грань. Ссылка, возвращаемая этой функцией, является действительным до тех пор, как любой std::locale объект существует, реализующий
Facet.Original:
Returns a reference the facet. The reference returned by this function is valid as long as any std::locale object exists that implements
Facet.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Исключения
std::bad_cast if std::has_facet<Facet>(loc) == false.
[править] Пример
Показать 3-письма название валюты используется предпочтительный язык пользователя
Original:
Display the 3-letter currency name used by the user's preferred locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#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'; }
Вывод:
Your currency string is USD
[править] См. также
| Набор полиморфных аспекты, которые инкапсулируют культурные различия Original: set of polymorphic facets that encapsulate cultural differences The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (класс) | |
| проверяет, является ли язык реализует определенный аспект Original: checks if a locale implements a specific facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон функции) | |