Document: N2733=08-0243
Date: 2008-08-22
Authors: Benjamin Kosnik <bkoz@redhat.com>
Appendix
C: ISO C++ 2003 Compatibility
General organization
and editorial
suggestions
This paper proposes a new section in Appendix C for compatibility between ISO
C++ 2003 and ISO C++200x.
C.1 C++ and ISO C
and
C.2 Standard C library
into one grouping for both language and library features, such that
C.1 C++ and ISO C
C.1.1 Clause 2: lexical conventions
...
C.1.9 Clause 16: preprocessing directives [diff.cpp]
remain as-is, and then
C.1.10 Clause 18
C.1.11 Clause 20
C.1.11 Clause 21
are added, and the contents of
C.2.1
C.2.2
C.2.3
C.2.4
are moved into the appropriate place in C.1.*. Consider this an editorial
suggestion.
Then, start with the C++2003 Compatibility with
C.2 C++ and ISO C++2003
And the rest of the text as is follows in this document.
If this arrangement is considered poor, then the existing layout can be used and C.3 C++ and ISO C++2003 can be used instead, and the text of this document can be added with the obvious transformation for whatever approved numbering scheme is in effect by the editor.
C.2.3 Clause 17 library introduction
17.4.1.3
Change: New includes.
Rationale: New functionality.
Effect on original feature: The following C++ include files
are new: array, chrono, initializer_list, mutex, random, ratio, regex,
sytem_error, and threads. In addition, the following C compatibility include
files are new: ccomplex, cfenv, cinttypes, cstdbool, cstdint, ctgmath, and
cuchar. Valid C++03 code that includes files with these names may be invalid
in C++0x.
17.4.3.1.2
Change: New reserved namespace.
Rationale: New functionality.
Effect on original feature: The global namespace posix is now
reserved for standardization. Valid C++03 code that used a top-level posix
namespace may be invalid in C++0x.
C.2.4 Clause 18 library support
18.7
18.8
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x.
New identifiers, by include file:
<exception>
nested_exception, exception_ptr, current_exception, rethrow_exception, copy_exception, throw_with_nested, and rethrow_if_nested.
<initializer_list>
initializer_list
18.5.1.1
Change: Linking new/delete operators.
Rationale: Two throwing single-object signatures form base for
other operators, clarifies that replacing these two changes others. Tighter
requirements increase portability.
Effect on original feature: Valid C++03 code that replaces
global new/delete operators may execute differently in C++0x.
For example:
#include <cstdio>
#include <cstdlib>
#include <new>
void* operator new(std::size_t size) throw(std::bad_alloc)
{
std::printf("custom allocation\n");
if (size == 0)
size = 1;
void*p = std::malloc(size);
if (p == 0)
throw std::bad_alloc();
return p;
}
void operator delete(void* ptr) throw()
{
&nb! sp; std::printf("custom deallocation\n");
std::free(ptr);
}
int main()
{
int* i = new int;
delete i;
int* a = new int[3];
delete [] a;
}
C.2.5 Clause 19 diagnostics
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
19.3
Change: Thread-local error numbers.
Rationale: Support new thread facilities.
Effect on original feature: Valid but implementation-defined
C++-03 code that relies on errno being the same across threads may change
behavior in C++-0x.
C.2.6 Clause 20 utilities
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
integral_constant, true_type, false_type,
is_void, is_integral, is_floating_point, is_array, is_pointer,
is_lvalue_reference, is_rvalue_reference, is_member_object_pointer,
is_member_function_pointer, is_enum, is_union, is_class, is_function,
is_reference, is_arithmetic, is_fundamental, is_member_pointer, is_scalar,
is_object, is_compound, is_const, is_volatile, is_trivial, is_standard_layout,
is_pod, is_empty, is_polymorphic, is_abstract, remove_const, remove_volatile,
remove_cv, add_const, add_volatile, add_cv, remove_reference, add_reference,
remove_pointer, add_pointer, is_signed, is_unsigned, rank, extent,
remove_extent, remove_all_extents, has_trivial_default_contructor,
has_trivial_copy_constructor, has_trivial_assign, has_trivial_destructor,
has_nothrow_default_constructor, has_nothrow_copy_constructor,
has_nothrow_assign, has_virtual_destructor, is_same, is_base_of,
is_convertible, aligned_storage, aligned_union, decay, enable_if,
conditional, common_type
<utility>
tuple_size, tuple_element, get
C.2.7 Clause 21 strings
21.2
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
C.2.8 Clause 23 containers
23.2
23.4
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
<array>
array, tuple_element, tuple_size, get
<forward_list>
forward_list
<unordered_map>
unordered_map, unordered_multimap
<unordered_set>
unordered_set, unordered_multiset
C.2.9 Clause 25 algorithms
25
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
<algorithm>
all_of, any_of, none_of, find_if_not, copy_n, copy_if, partition_copy,
partition_point
C.2.10 Clause 26 numerics
26.4.2
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
<random>
linear_congruential_engine, mersenne_twister_engine, subtract_with_carry_engine, discard_block_engine, independent_bits_engine, shuffle_order_engine, minstd_rand0, minstd_rand, mt19937, ranlux24_base, ranlux48_bse, ranlux24, ranlux48, knuth_b, default_random_engine, random_device, seed_seq, generate_cannonical, uniform_int_distribution, uniform_real_distribution, bernoulli_distribution, binomial_distribution, geometric_distribution, negative_binomial_distribution, poisson_distribution, exponential_distribution, gamma_distribution, weibull_distribution, extreme_value_distribution, normal_distribution, lognormal_distribution, chi_squared_distribution, cauchy_distribution, fisher_f_distribution, student_t_distribution, discrete_distribution, piecewise_constant_distribution, general_pdf_distribution
C.2.11 Clause 27 io
Change: Change ios_base:: types that are bitmasks to be an
enumeration with constexpr overloads.
Rationale: All bitmask types should be defined as enumerations
with mask operators implemented as constexpr functions.
Effect on original feature: Define ios_base::fmtflags,
ios_base::iostate, ios_base::openmode, ios_base::seekdir as enumerations.
Some code that depended on the implementation properties of these types being std::bitset or a builtin integer type may no longer compile.
For example:
#include <iostream>
std::cout.setf(17); // should be std::cout.setf(hex);
C.2.12 Clause 28 regex
28.4
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
<regex>
regex_constants, regex_error, regex_traits, basic_regex, regex, wregex, sub_match, csub_match, wcsub_match, ssub_match, wssub_match, match_results, cmatch, wcmatch, smatch, wsmatch, regex_match, regex_search, regex_replace, regex_iterator, cregex_iterator, wcregex_iterator, sregex_iterator, wsregex_iterator, regex_token_iterator, cregex_token_iterator, wcregex_token_iterator, sregex_token_iterator, wsregex_token_iterator.
C.2.13 Clause 29 atomics
29.0
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
<cstdatomic>
memory_order, kill_dependency, atomic_flag, atomic_flag_test_and_set, atomic_flag_test_and_set_explicit, atomic_flag_clear, atomic_flag_clear_explicit, atomic_flag_fence, atomic_global_fence_compatibility, atomic_is_lock_free, atomic_store, atomic_store_explicit, atomic_load, atomic_load_explicit, atomic_exchange, atomic_exchange_explicit, atomic_compare_exchange, atomic_compare_exchange_explicit, atomic_fence, atomic_fence, atomic_fetch_add, atomic_fetch_add_explicit, atomic_fetch_sub, atomic_fetch_sub_explicit, atomic, atomic_address, atomic_bool, atomic_char, atomic_schar, atomic_uchar, atomic_short, atomic_ushort, atomic_int, atomic_uint, atomic_long, atomic_ulong, atomic_llong, atomic_ullong, atomic_wchar_t, atomic_char16_t, atomic_char32_t
C.2.14 Clause 30 threads
30.2
30.3
30.4
Change: New reserved identifiers.
Rationale: Required by new features.
Effect on original feature: Valid C++03 code that uses these
identifiers may be invalid in C++0x. New identifiers, by include file:
<thread>
thread, this_thread
<mutex>
mutex, recursive_mutex, timed_mutex, recursive_timed_mutex, defer_lock_t, try_to_lock_t, adopt_lock_t, defer_lock, try_to_lock, adopt_lock, try_lock, lock, once_flag, call_once
<condition_variable>
condition_variable, condition_variable_any