Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::locale::combine

      From cppreference.com
      <cpp‎ |locale‎ |locale
       
       
       
      Localization library
       
       
      template<class Facet>
      locale combine(const locale& other)const;

      Constructs a locale object which is a copy of*this except for the facet of typeFacet, which is copied fromother.

      The program is ill-formed if Facet is not afacet or it is a volatile-qualified facet.

      Contents

      [edit]Return value

      The new, nameless, locale.

      [edit]Exceptions

      std::runtime_error ifother does not implementFacet.

      [edit]Example

      Run this code
      #include <iostream>#include <locale> int main(){constdouble number=1000.25;std::cout<<"\"C\" locale: "<< number<<'\n';std::locale loc=std::locale()        .combine<std::numpunct<char>>(std::locale("en_US.UTF8"));std::cout.imbue(loc);std::cout<<"\"C\" locale with en_US numpunct: "<< number<<'\n';}

      Output:

      "C" locale: 1000.25"C" locale with en_US numpunct: 1,000.25

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 14C++98locale::combine was non-constmade const
      LWG 436C++98it was unclear whetherFacet can be cv-qualifiedit can be const-qualified, but not volatile-qualified

      [edit]See also

      constructs a new locale
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/locale/combine&oldid=177154"

      [8]ページ先頭

      ©2009-2025 Movatter.jp