##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::locale::combine

From cppreference.com
< cpp‎ | locale‎ | locale

Defined in header `<locale>` |  |
template< class Facet > locale combine( const locale& other ) const; |  |

Constructs a locale object which is a copy of *this except for the facet of type `Facet`, which is copied from `other`.

### [edit] Return value

The new, nameless, locale.

### [edit] Exceptions

std::runtime_error if `other` does not implement `Facet`

### [edit] Example

Run this code

    #include <iostream>
    #include <locale>

    int main()
    {
        const double 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] See also

(constructor) | constructs a new locale (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/locale/locale/combine&oldid=58145"