[diff.cpp03] # Annex C (informative) Compatibility [[diff]](./#diff) ## C.6 C++ and ISO C++ 2003 [diff.cpp03] ### [C.6.1](#general) General [[diff.cpp03.general]](diff.cpp03.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2121) Subclause [diff.cpp03] lists the differences between C++ and ISO C++ 2003, in addition to those listed above, by the chapters of this document[.](#general-1.sentence-1) ### [C.6.2](#lex) [[lex]](lex "5 Lexical conventions"): lexical conventions [[diff.cpp03.lex]](diff.cpp03.lex) [1](#lex-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2130) **Affected subclause:** [[lex.pptoken]](lex.pptoken) **Change:** New kinds of [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]")*s*[.](#lex-1.sentence-1) **Rationale:** Required for new features[.](#lex-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in this revision of C++[.](#lex-1.sentence-3) Specifically, macros named R, u8,u8R, u, uR, U, UR, or LR will not be expanded when adjacent to a [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]") but will be interpreted as part of the [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]")[.](#lex-1.sentence-4) [*Example [1](#lex-example-1)*: #define u8 "abc"const char* s = u8"def"; // Previously "abcdef", now "def" — *end example*] [2](#lex-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2148) **Affected subclause:** [[lex.pptoken]](lex.pptoken) **Change:** User-defined literal string support[.](#lex-2.sentence-1) **Rationale:** Required for new features[.](#lex-2.sentence-2) **Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in this revision of C++[.](#lex-2.sentence-3) [*Example [2](#lex-example-2)*: #define _x "there""hello"_x // #1 Previously, #1 would have consisted of two separate preprocessing tokens and the macro _x would have been expanded[.](#lex-2.sentence-4) In this revision of C++, #1 consists of a single preprocessing token, so the macro is not expanded[.](#lex-2.sentence-5) — *end example*] [3](#lex-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2167) **Affected subclause:** [[lex.key]](lex.key) **Change:** New keywords[.](#lex-3.sentence-1) **Rationale:** Required for new features[.](#lex-3.sentence-2) **Effect on original feature:** Added to Table [5](lex.key#tab:lex.key "Table 5: Keywords"), the following identifiers are new keywords:alignas,alignof,char16_t,char32_t,constexpr,decltype,noexcept,nullptr,static_assert, andthread_local[.](#lex-3.sentence-3) Valid C++ 2003 code using these identifiers is invalid in this revision of C++[.](#lex-3.sentence-4) [4](#lex-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2187) **Affected subclause:** [[lex.icon]](lex.icon) **Change:** Type of integer literals[.](#lex-4.sentence-1) **Rationale:** C99 compatibility[.](#lex-4.sentence-2) **Effect on original feature:** Certain integer literals larger than can be represented by long could change from an unsigned integer type to signed long long[.](#lex-4.sentence-3) ### [C.6.3](#expr) [[expr]](expr "7 Expressions"): expressions [[diff.cpp03.expr]](diff.cpp03.expr) [1](#expr-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2198) **Affected subclause:** [[conv.ptr]](conv.ptr) **Change:** Only literals are integer null pointer constants[.](#expr-1.sentence-1) **Rationale:** Removing surprising interactions with templates and constant expressions[.](#expr-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in this revision of C++[.](#expr-1.sentence-3) [*Example [1](#expr-example-1)*: void f(void *); // #1void f(...); // #2template void g() { f(0*N); // calls #2; used to call #1} — *end example*] [2](#expr-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2217) **Affected subclause:** [[expr.typeid]](expr.typeid) **Change:** Evaluation of operands in typeid[.](#expr-2.sentence-1) **Rationale:** Introduce additional expression value categories[.](#expr-2.sentence-2) **Effect on original feature:** Valid C++ 2003 code that uses xvalues as operands for typeid may change behavior in this revision of C++[.](#expr-2.sentence-3) [*Example [2](#expr-example-2)*: void f() {struct B { B() {}virtual ~B() { }}; struct C { B b; }; typeid(C().b); // unevaluated in C++ 2003, evaluated in C++ 2011} — *end example*] [3](#expr-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2239) **Affected subclause:** [[expr.mul]](expr.mul) **Change:** Specify rounding for results of integer / and %[.](#expr-3.sentence-1) **Rationale:** Increase portability, C99 compatibility[.](#expr-3.sentence-2) **Effect on original feature:** Valid C++ 2003 code that uses integer division rounds the result toward 0 or toward negative infinity, whereas this revision of C++ always rounds the result toward 0[.](#expr-3.sentence-3) [4](#expr-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2249) **Affected subclause:** [[expr.log.and]](expr.log.and) **Change:** && is valid in a [*type-name*](dcl.type.simple#nt:type-name "9.2.9.3 Simple type specifiers [dcl.type.simple]")[.](#expr-4.sentence-1) **Rationale:** Required for new features[.](#expr-4.sentence-2) **Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in this revision of C++[.](#expr-4.sentence-3) [*Example [3](#expr-example-3)*: bool b1 = new int && false; // previously false, now ill-formedstruct S { operator int(); };bool b2 = &S::operator int && false; // previously false, now ill-formed — *end example*] [5](#expr-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2265) **Affected subclause:** [[expr.cond]](expr.cond) **Change:** Fewer copies in the conditional operator[.](#expr-5.sentence-1) **Rationale:** Introduce additional expression value categories[.](#expr-5.sentence-2) **Effect on original feature:** Valid C++ 2003 code that uses xvalues as operands for the conditional operator may change behavior in this revision of C++[.](#expr-5.sentence-3) [*Example [4](#expr-example-4)*: void f() {struct B { B() {} B(const B&) { }}; struct D : B {}; struct BB { B b; }; struct DD { D d; }; true ? BB().b : DD().d; // additional copy in C++ 2003, no copy or move in C++ 2011} — *end example*] ### [C.6.4](#dcl.dcl) [[dcl]](dcl "9 Declarations"): declarations [[diff.cpp03.dcl.dcl]](diff.cpp03.dcl.dcl) [1](#dcl.dcl-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2292) **Affected subclause:** [[dcl.spec]](dcl.spec) **Change:** Remove auto as a storage class specifier[.](#dcl.dcl-1.sentence-1) **Rationale:** New feature[.](#dcl.dcl-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code that uses the keyword auto as a storage class specifier may be invalid in this revision of C++[.](#dcl.dcl-1.sentence-3) In this revision of C++,auto indicates that the type of a variable is to be deduced from its initializer expression[.](#dcl.dcl-1.sentence-4) [2](#dcl.dcl-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2305) **Affected subclause:** [[dcl.init.list]](dcl.init.list) **Change:** Narrowing restrictions in aggregate initializers[.](#dcl.dcl-2.sentence-1) **Rationale:** Catches bugs[.](#dcl.dcl-2.sentence-2) **Effect on original feature:** Valid C++ 2003 code may fail to compile in this revision of C++[.](#dcl.dcl-2.sentence-3) [*Example [1](#dcl.dcl-example-1)*: int x[] = { 2.0 }; This code is valid in C++ 2003 but invalid in this revision of C++ because double to int is a narrowing conversion[.](#dcl.dcl-2.sentence-4) — *end example*] [3](#dcl.dcl-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2321) **Affected subclause:** [[dcl.link]](dcl.link) **Change:** Names declared in an anonymous namespace changed from external linkage to internal linkage; language linkage applies to names with external linkage only[.](#dcl.dcl-3.sentence-1) **Rationale:** Alignment with user expectations[.](#dcl.dcl-3.sentence-2) **Effect on original feature:** Valid C++ 2003 code may violate the one-definition rule ([[basic.def.odr]](basic.def.odr "6.3 One-definition rule")) in this revision of C++[.](#dcl.dcl-3.sentence-3) [*Example [2](#dcl.dcl-example-2)*: namespace { extern "C" { extern int x; } } // #1, previously external linkage and C language linkage,// now internal linkage and C++ language linkagenamespace A { extern "C" int x = 42; } // #2, external linkage and C language linkageint main(void) { return x; } This code is valid in C++ 2003, but #2 is not a definition for #1 in this revision of C++, violating the one-definition rule[.](#dcl.dcl-3.sentence-4) — *end example*] ### [C.6.5](#class) [[class]](class "11 Classes"): classes [[diff.cpp03.class]](diff.cpp03.class) [1](#class-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2345) **Affected subclauses:** [[class.default.ctor]](class.default.ctor), [[class.dtor]](class.dtor), [[class.copy.ctor]](class.copy.ctor), and [[class.copy.assign]](class.copy.assign) **Change:** Implicitly-declared special member functions are defined as deleted when the implicit definition would have been ill-formed[.](#class-1.sentence-1) **Rationale:** Improves template argument deduction failure[.](#class-1.sentence-2) **Effect on original feature:** A valid C++ 2003 program that uses one of these special member functions in a context where the definition is not required (e.g., in an expression that is not potentially evaluated) becomes ill-formed[.](#class-1.sentence-3) [2](#class-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2356) **Affected subclause:** [[class.dtor]](class.dtor) **Change:** User-declared destructors have an implicit exception specification[.](#class-2.sentence-1) **Rationale:** Clarification of destructor requirements[.](#class-2.sentence-2) **Effect on original feature:** Valid C++ 2003 code may execute differently in this revision of C++[.](#class-2.sentence-3) In particular, destructors that throw exceptions will call std​::​terminate (without calling std​::​unexpected) if their exception specification is non-throwing[.](#class-2.sentence-4) ### [C.6.6](#temp) [[temp]](temp "13 Templates"): templates [[diff.cpp03.temp]](diff.cpp03.temp) [1](#temp-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2369) **Affected subclause:** [[temp.param]](temp.param) **Change:** Repurpose export for modules ([[module]](module "10 Modules"), [[cpp.module]](cpp.module "15.5 Module directive"), [[cpp.import]](cpp.import "15.6 Header unit importation"))[.](#temp-1.sentence-1) **Rationale:** No implementation consensus for the C++ 2003 meaning of export[.](#temp-1.sentence-2) **Effect on original feature:** A valid C++ 2003 program containing export is ill-formed in this revision of C++[.](#temp-1.sentence-3) [2](#temp-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2378) **Affected subclause:** [[temp.arg]](temp.arg) **Change:** Remove whitespace requirement for nested closing template right angle brackets[.](#temp-2.sentence-1) **Rationale:** Considered a persistent but minor annoyance[.](#temp-2.sentence-2) Template aliases representing non-class types would exacerbate whitespace issues[.](#temp-2.sentence-3) **Effect on original feature:** Change to semantics of well-defined expression[.](#temp-2.sentence-4) A valid C++ 2003 expression containing a right angle bracket (“>”) followed immediately by another right angle bracket may now be treated as closing two templates[.](#temp-2.sentence-5) [*Example [1](#temp-example-1)*: template struct X { };template struct Y { }; X< Y< 1 >> 2 > > x; This code is valid in C++ 2003 because “>>” is a right-shift operator, but invalid in this revision of C++ because “>>” closes two templates[.](#temp-2.sentence-6) — *end example*] [3](#temp-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2400) **Affected subclause:** [[temp.dep.candidate]](temp.dep.candidate) **Change:** Allow dependent calls of functions with internal linkage[.](#temp-3.sentence-1) **Rationale:** Overly constrained, simplify overload resolution rules[.](#temp-3.sentence-2) **Effect on original feature:** A valid C++ 2003 program can get a different result in this revision of C++[.](#temp-3.sentence-3) ### [C.6.7](#library) [[library]](library "16 Library introduction"): library introduction [[diff.cpp03.library]](diff.cpp03.library) [1](#library-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2411) **Affected:** [[library]](library "16 Library introduction") – [[exec]](exec "33 Execution control library") **Change:** New reserved identifiers[.](#library-1.sentence-2) **Rationale:** Required by new features[.](#library-1.sentence-3) **Effect on original feature:** Valid C++ 2003 code that uses any identifiers added to the C++ standard library by later revisions of C++ may fail to compile or produce different results in this revision of C++[.](#library-1.sentence-4) A comprehensive list of identifiers used by the C++ standard library can be found in the Index of Library Names in this document[.](#library-1.sentence-5) [2](#library-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2424) **Affected subclause:** [[headers]](headers) **Change:** New headers[.](#library-2.sentence-1) **Rationale:** New functionality[.](#library-2.sentence-2) **Effect on original feature:** The following C++ headers are new:[](array.syn#header:%3carray%3e "23.3.2 Header synopsis [array.syn]"),[](atomics.syn#header:%3catomic%3e "32.5.2 Header synopsis [atomics.syn]"),[](time.syn#header:%3cchrono%3e "30.2 Header synopsis [time.syn]"),[](condition.variable.syn#header:%3ccondition_variable%3e "32.7.2 Header synopsis [condition.variable.syn]"),[](forward.list.syn#header:%3cforward_list%3e "23.3.6 Header synopsis [forward.list.syn]"),[](future.syn#header:%3cfuture%3e "32.10.2 Header synopsis [future.syn]"), ([[initializer.list.syn]](initializer.list.syn "17.11.2 Header synopsis")),[](mutex.syn#header:%3cmutex%3e "32.6.2 Header synopsis [mutex.syn]"),[](rand.synopsis#header:%3crandom%3e "29.5.2 Header synopsis [rand.synopsis]"),[](ratio.syn#header:%3cratio%3e "21.5.2 Header synopsis [ratio.syn]"),[](re.syn#header:%3cregex%3e "28.6.3 Header synopsis [re.syn]"),[](allocator.adaptor.syn#header:%3cscoped_allocator%3e "20.6.1 Header synopsis [allocator.adaptor.syn]"),[](system.error.syn#header:%3csystem_error%3e "19.5.2 Header synopsis [system.error.syn]"),[](thread.syn#header:%3cthread%3e "32.4.2 Header synopsis [thread.syn]"),[](tuple.syn#header:%3ctuple%3e "22.4.2 Header synopsis [tuple.syn]"), ([[type.index.synopsis]](type.index.synopsis "17.7.6 Header synopsis")),[](meta.type.synop#header:%3ctype_traits%3e "21.3.3 Header synopsis [meta.type.synop]"),[](unord.map.syn#header:%3cunordered_map%3e "23.5.2 Header synopsis [unord.map.syn]"), and[](unord.set.syn#header:%3cunordered_set%3e "23.5.5 Header synopsis [unord.set.syn]")[.](#library-2.sentence-3) In addition the following C compatibility headers are new:[](cfenv.syn#header:%3ccfenv%3e "29.3.1 Header synopsis [cfenv.syn]"),[](cinttypes.syn#header:%3ccinttypes%3e "31.13.2 Header synopsis [cinttypes.syn]"),[](cstdint.syn#header:%3ccstdint%3e "17.4.1 Header synopsis [cstdint.syn]"), and[](cuchar.syn#header:%3ccuchar%3e "28.7.4 Header synopsis [cuchar.syn]")[.](#library-2.sentence-4) Valid C++ 2003 code that #includes headers with these names may be invalid in this revision of C++[.](#library-2.sentence-5) [3](#library-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2460) **Affected subclause:** [[swappable.requirements]](swappable.requirements) **Change:** Function swap moved to a different header[.](#library-3.sentence-1) **Rationale:** Remove dependency on [](algorithm.syn#header:%3calgorithm%3e "26.4 Header synopsis [algorithm.syn]") for swap[.](#library-3.sentence-2) **Effect on original feature:** Valid C++ 2003 code that has been compiled expecting swap to be in[](algorithm.syn#header:%3calgorithm%3e "26.4 Header synopsis [algorithm.syn]") may have to instead include [](utility.syn#header:%3cutility%3e "22.2.1 Header synopsis [utility.syn]")[.](#library-3.sentence-3) [4](#library-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2469) **Affected subclause:** [[namespace.posix]](namespace.posix) **Change:** New reserved namespace[.](#library-4.sentence-1) **Rationale:** New functionality[.](#library-4.sentence-2) **Effect on original feature:** The global namespace posix is now reserved for standardization[.](#library-4.sentence-3) Valid C++ 2003 code that uses a top-level namespace posix may be invalid in this revision of C++[.](#library-4.sentence-4) [5](#library-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2479) **Affected subclause:** [[macro.names]](macro.names) **Change:** Additional restrictions on macro names[.](#library-5.sentence-1) **Rationale:** Avoid hard to diagnose or non-portable constructs[.](#library-5.sentence-2) **Effect on original feature:** Names of attribute identifiers may not be used as macro names[.](#library-5.sentence-3) Valid C++ 2003 code that defines override, final, ornoreturn as macros is invalid in this revision of C++[.](#library-5.sentence-4) ### [C.6.8](#language.support) [[support]](support "17 Language support library"): language support library [[diff.cpp03.language.support]](diff.cpp03.language.support) [1](#language.support-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2493) **Affected subclause:** [[new.delete.single]](new.delete.single) **Change:** operator new may throw exceptions other thanstd​::​bad_alloc[.](#language.support-1.sentence-1) **Rationale:** Consistent application of noexcept[.](#language.support-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code that assumes that global operator new only throws std​::​bad_alloc may execute differently in this revision of C++[.](#language.support-1.sentence-3) Valid C++ 2003 code that replaces the global replaceable operator new is ill-formed in this revision of C++, because the exception specification of throw(std​::​bad_alloc) was removed[.](#language.support-1.sentence-4) ### [C.6.9](#diagnostics) [[diagnostics]](diagnostics "19 Diagnostics library"): diagnostics library [[diff.cpp03.diagnostics]](diff.cpp03.diagnostics) [1](#diagnostics-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2509) **Affected subclause:** [[errno]](errno) **Change:** Thread-local error numbers[.](#diagnostics-1.sentence-1) **Rationale:** Support for new thread facilities[.](#diagnostics-1.sentence-2) **Effect on original feature:** Valid but implementation-specific C++ 2003 code that relies onerrno being the same across threads may change behavior in this revision of C++[.](#diagnostics-1.sentence-3) ### [C.6.10](#utilities) [[utilities]](utilities "22 General utilities library"): general utilities library [[diff.cpp03.utilities]](diff.cpp03.utilities) [1](#utilities-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2521) **Affected subclauses:** [[refwrap]](refwrap), [[arithmetic.operations]](arithmetic.operations), [[comparisons]](comparisons), [[logical.operations]](logical.operations), and [[bitwise.operations]](bitwise.operations) **Change:** Standard function object types no longer derived fromstd​::​unary_function or std​::​binary_function[.](#utilities-1.sentence-1) **Rationale:** Superseded by new feature; unary_function andbinary_function are no longer defined[.](#utilities-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code that depends on function object types being derived fromunary_function or binary_function may fail to compile in this revision of C++[.](#utilities-1.sentence-3) ### [C.6.11](#strings) [[strings]](strings "27 Strings library"): strings library [[diff.cpp03.strings]](diff.cpp03.strings) [1](#strings-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2535) **Affected subclause:** [[string.classes]](string.classes) **Change:** basic_string requirements no longer allow reference-counted strings[.](#strings-1.sentence-1) **Rationale:** Invalidation is subtly different with reference-counted strings[.](#strings-1.sentence-2) This change regularizes behavior[.](#strings-1.sentence-3) **Effect on original feature:** Valid C++ 2003 code may execute differently in this revision of C++[.](#strings-1.sentence-4) [2](#strings-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2545) **Affected subclause:** [[string.require]](string.require) **Change:** Loosen basic_string invalidation rules[.](#strings-2.sentence-1) **Rationale:** Allow small-string optimization[.](#strings-2.sentence-2) **Effect on original feature:** Valid C++ 2003 code may execute differently in this revision of C++[.](#strings-2.sentence-3) Some const member functions, such as data and c_str, no longer invalidate iterators[.](#strings-2.sentence-4) ### [C.6.12](#containers) [[containers]](containers "23 Containers library"): containers library [[diff.cpp03.containers]](diff.cpp03.containers) [1](#containers-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2557) **Affected subclause:** [[container.requirements]](container.requirements) **Change:** Complexity of size() member functions now constant[.](#containers-1.sentence-1) **Rationale:** Lack of specification of complexity of size() resulted in divergent implementations with inconsistent performance characteristics[.](#containers-1.sentence-2) **Effect on original feature:** Some container implementations that conform to C++ 2003 may not conform to the specified size() requirements in this revision of C++[.](#containers-1.sentence-3) Adjusting containers such as std​::​list to the stricter requirements may require incompatible changes[.](#containers-1.sentence-4) [2](#containers-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2569) **Affected subclause:** [[container.requirements]](container.requirements) **Change:** Requirements change: relaxation[.](#containers-2.sentence-1) **Rationale:** Clarification[.](#containers-2.sentence-2) **Effect on original feature:** Valid C++ 2003 code that attempts to meet the specified container requirements may now be over-specified[.](#containers-2.sentence-3) Code that attempted to be portable across containers may need to be adjusted as follows: - [(2.1)](#containers-2.1) not all containers provide size(); use empty() instead of size() == 0; - [(2.2)](#containers-2.2) not all containers are empty after construction (array); - [(2.3)](#containers-2.3) not all containers have constant complexity for swap() (array)[.](#containers-2.sentence-4) [3](#containers-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2585) **Affected subclause:** [[container.requirements]](container.requirements) **Change:** Requirements change: default constructible[.](#containers-3.sentence-1) **Rationale:** Clarification of container requirements[.](#containers-3.sentence-2) **Effect on original feature:** Valid C++ 2003 code that attempts to explicitly instantiate a container using a user-defined type with no default constructor may fail to compile[.](#containers-3.sentence-3) [4](#containers-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2594) **Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts) **Change:** Signature changes: from void return types[.](#containers-4.sentence-1) **Rationale:** Old signature threw away useful information that may be expensive to recalculate[.](#containers-4.sentence-2) **Effect on original feature:** The following member functions have changed: - [(4.1)](#containers-4.1) erase(iter) for set, multiset, map, multimap - [(4.2)](#containers-4.2) erase(begin, end) for set, multiset, map, multimap - [(4.3)](#containers-4.3) insert(pos, num, val) for vector, deque, list, forward_list - [(4.4)](#containers-4.4) insert(pos, beg, end) for vector, deque, list, forward_list Valid C++ 2003 code that relies on these functions returning void (e.g., code that creates a pointer to member function that points to one of these functions) will fail to compile with this revision of C++[.](#containers-4.sentence-4) [5](#containers-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2613) **Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts) **Change:** Signature changes: from iterator to const_iterator parameters[.](#containers-5.sentence-1) **Rationale:** Overspecification[.](#containers-5.sentence-2) **Effect on original feature:** The signatures of the following member functions changed from taking aniterator to taking a const_iterator: - [(5.1)](#containers-5.1) insert(iter, val) for vector, deque, list,set, multiset, map, multimap - [(5.2)](#containers-5.2) insert(pos, beg, end) for vector, deque, list,forward_list - [(5.3)](#containers-5.3) erase(begin, end) for set, multiset, map, multimap - [(5.4)](#containers-5.4) all forms of list​::​splice - [(5.5)](#containers-5.5) all forms of list​::​merge Valid C++ 2003 code that uses these functions may fail to compile with this revision of C++[.](#containers-5.sentence-4) [6](#containers-6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2635) **Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts) **Change:** Signature changes: resize[.](#containers-6.sentence-1) **Rationale:** Performance, compatibility with move semantics[.](#containers-6.sentence-2) **Effect on original feature:** For vector, deque, and list the fill value passed to resize is now passed by reference instead of by value, and an additional overload of resize has been added[.](#containers-6.sentence-3) Valid C++ 2003 code that uses this function may fail to compile with this revision of C++[.](#containers-6.sentence-4) ### [C.6.13](#algorithms) [[algorithms]](algorithms "26 Algorithms library"): algorithms library [[diff.cpp03.algorithms]](diff.cpp03.algorithms) [1](#algorithms-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2648) **Affected subclause:** [[algorithms.general]](algorithms.general) **Change:** Result state of inputs after application of some algorithms[.](#algorithms-1.sentence-1) **Rationale:** Required by new feature[.](#algorithms-1.sentence-2) **Effect on original feature:** A valid C++ 2003 program may detect that an object with a valid but unspecified state has a different valid but unspecified state with this revision of C++[.](#algorithms-1.sentence-3) For example, std​::​remove andstd​::​remove_if may leave the tail of the input sequence with a different set of values than previously[.](#algorithms-1.sentence-4) ### [C.6.14](#numerics) [[numerics]](numerics "29 Numerics library"): numerics library [[diff.cpp03.numerics]](diff.cpp03.numerics) [1](#numerics-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2662) **Affected subclause:** [[complex.numbers]](complex.numbers) **Change:** Specified representation of complex numbers[.](#numerics-1.sentence-1) **Rationale:** Compatibility with C99[.](#numerics-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code that uses implementation-specific knowledge about the binary representation of the required template specializations ofstd​::​complex may not be compatible with this revision of C++[.](#numerics-1.sentence-3) ### [C.6.15](#locale) [[localization]](localization "28.3 Localization library"): localization library [[diff.cpp03.locale]](diff.cpp03.locale) [1](#locale-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2674) **Affected subclause:** [[facet.num.get.virtuals]](facet.num.get.virtuals) **Change:** The num_get facet recognizes hexadecimal floating point values[.](#locale-1.sentence-1) **Rationale:** Required by new feature[.](#locale-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code may have different behavior in this revision of C++[.](#locale-1.sentence-3) ### [C.6.16](#input.output) [[input.output]](input.output "31 Input/output library"): input/output library [[diff.cpp03.input.output]](diff.cpp03.input.output) [1](#input.output-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2684) **Affected subclauses:** [[istream.sentry]](istream.sentry), [[ostream.sentry]](ostream.sentry), and [[iostate.flags]](iostate.flags) **Change:** Specify use of explicit in existing boolean conversion functions[.](#input.output-1.sentence-1) **Rationale:** Clarify intentions, avoid workarounds[.](#input.output-1.sentence-2) **Effect on original feature:** Valid C++ 2003 code that relies on implicit boolean conversions will fail to compile with this revision of C++[.](#input.output-1.sentence-3) Such conversions occur in the following conditions: - [(1.1)](#input.output-1.1) passing a value to a function that takes an argument of type bool; - [(1.2)](#input.output-1.2) using operator== to compare to false or true; - [(1.3)](#input.output-1.3) returning a value from a function with a return type of bool; - [(1.4)](#input.output-1.4) initializing members of type bool via aggregate initialization; - [(1.5)](#input.output-1.5) initializing a const bool& which would bind to a temporary object[.](#input.output-1.sentence-4) [2](#input.output-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2701) **Affected subclause:** [[ios.failure]](ios.failure) **Change:** Change base class of std​::​ios_base​::​failure[.](#input.output-2.sentence-1) **Rationale:** More detailed error messages[.](#input.output-2.sentence-2) **Effect on original feature:** std​::​ios_base​::​failure is no longer derived directly fromstd​::​exception, but is now derived from std​::​system_error, which in turn is derived from std​::​runtime_error[.](#input.output-2.sentence-3) Valid C++ 2003 code that assumes that std​::​ios_base​::​failure is derived directly fromstd​::​exception may execute differently in this revision of C++[.](#input.output-2.sentence-4) [3](#input.output-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2713) **Affected subclause:** [[ios.base]](ios.base) **Change:** Flag types in std​::​ios_base are now bitmasks with values defined as constexpr static members[.](#input.output-3.sentence-1) **Rationale:** Required for new features[.](#input.output-3.sentence-2) **Effect on original feature:** Valid C++ 2003 code that relies on std​::​ios_base flag types being represented as std​::​bitset or as an integer type may fail to compile with this revision of C++[.](#input.output-3.sentence-3) [*Example [1](#input.output-example-1)*: #include int main() {int flag = std::ios_base::hex; std::cout.setf(flag); // error: setf does not take argument of type int} — *end example*]