Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::locale::id

      From cppreference.com
      <cpp‎ |locale‎ |locale
       
       
       
      Localization library
       
       
      Defined in header<locale>
      class locale::id;

      The classstd::locale::id provides implementation-specific identification of a locale facet. Eachfacet has a public static member namedid of typestd::locale::id and eachstd::locale object maintains a list of facets it implements, indexed by theirids.

      Facets with the sameid belong to the same facet category and replace each other when added to a locale object.

      [edit]Member functions

      constructs a new id
      (public member function)
      operator=
      copy assignment operator is deleted
      (public member function)

      [edit]Example

      The following example shows how to construct a minimal custom facet.

      Run this code
      #include <iostream>#include <locale> struct myfacet:std::locale::facet{    myfacet(std::size_t refs=0): facet(refs){}static::std::locale::id id;}; std::locale::id myfacet::id; int main(){std::locale myloc(std::locale(), new myfacet);std::cout<<"has_facet<myfacet>(myloc) returns "<<std::boolalpha<<std::has_facet<myfacet>(myloc)<<'\n';}

      Output:

      has_facet<myfacet>(myloc) returns true

      [edit]See also

      the base class for all facet categories: each facet of any category is derived from this type
      (class)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/locale/id&oldid=179681"

      [8]ページ先頭

      ©2009-2025 Movatter.jp