Title
locale immutability and locale::operator=()
Status
dup
Section
[locale]
Submitter
Martin Sebor

Created on 2002-09-06.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

[ Summer '04 mid-meeting mailing: Martin and Dietmar believe this is a duplicate of issue 31 and recommend that it be closed. ]

Duplicate: 31

Date: 2002-09-06.00:00:00

I think there is a problem with 22.1.1, p6 which says that

    -6- An instance of locale is immutable; once a facet reference
        is obtained from it, that reference remains usable as long
        as the locale value itself exists.

and 22.1.1.2, p4:

    const locale& operator=(const locale& other) throw();

    -4- Effects: Creates a copy of other, replacing the current value.

How can a reference to a facet obtained from a locale object remain valid after an assignment that clearly must replace all the facets in the locale object? Imagine a program such as this

    std::locale loc ("de_DE");
    const std::ctype<char> &r0 = std::use_facet<std::ctype<char> >(loc);
    loc = std::locale ("en_US");
    const std::ctype<char> &r1 = std::use_facet<std::ctype<char> >(loc);

Is r0 really supposed to be preserved and destroyed only when loc goes out of scope?

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2409
2002-09-06 00:00:00admincreate