C++03規格時点で存在したユーティリティライブラリに対するC++11規格での変更点をまとめています。
概要 †
当文書では、特定のカテゴリに含まれないヘッダファイル群について、C++11規格での変更点をまとめている。
共通の変更点 †
ここに記載した内容は個々のヘッダファイルの項には記載しない。
各クラスの throw()
指定されていたコンストラクタおよびメンバ関数から指定が外され、代わりに 条件式なしの noexcept
指定が付与された。
各クラスの throw()
指定されていたデストラクタから指定が外された。
代わりには何も指定されないが、C++11規格により暗黙の noexcept
となる。
throw()
指定されていたフリー関数から指定が外され、代わりに 条件式なしの noexcept
指定が付与された。
<exception> †
<locale> †
locale クラス †
下記のコンストラクタが追加された。
| explicit locale(const string& loc_name);
locale (const locale& src, const string& loc_name, category categories);
|
local::facet クラス †
local::id クラス †
ctype_base クラス †
ctype クラステンプレート †
local::facet クラスおよび ctype_base
クラスを継承しており、継承元の変更点も引き継ぐ。
codecvt クラステンプレート †
local::facet クラスを継承しており、それらの変更点も引き継ぐ。
num_get クラステンプレート †
local::facet クラスを継承しており、それらの変更点も引き継ぐ。
下記のメンバ関数オーバロードが定義された。
| iter_type get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
long long& value) const;
iter_type get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
unsigned long long& value) const;
protected:
virtual iter_type do_get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
long long& value) const;
protected:
virtual iter_type do_get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
unsigned long long& value) const;
|
num_put クラステンプレート †
local::facet クラスを継承しており、それらの変更点も引き継ぐ。
下記のメンバ関数オーバロードが定義された。
| iter_type put(iter_type first, ios_base& out, char_type c, long long value) const;
iter_type put(
iter_type first,
ios_base& out,
char_type c,
unsigned long long value) const;
protected:
virtual iter_type do_put(
iter_type first,
ios_base& out,
char_type c,
long long value) const;
protected:
virtual iter_type do_put(
iter_type first,
ios_base& out,
char_type c,
unsigned long long value) const;
|
time_get クラステンプレート †
local::facet クラスを継承しており、それらの変更点も引き継ぐ。
下記のメンバ関数が定義された。
| iter_type get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
tm* t,
char format,
char modifier = 0) const;
iter_type get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
tm* t,
const char_type* format_begin,
const char_type* format_end) const;
|
| protected:
virtual iter_type do_get(
iter_type first,
iter_type last,
ios_base& in,
ios_base::iostate& err,
tm* t,
char format,
char modifier = 0) const;
|
<locale> その他 †
<memory> †
allocator クラステンプレート †
メンバ型 propagate_on_container_move_assignment
が定義された。
| typedef true_type propagate_on_container_move_assignment;
|
メンバ関数 construct
の定義が変更された。
| void construct(pointer p, const_reference value);
|
| template<class U, class ...Args>
void construct(U* p, Args&&... args);
|
メンバ関数 destroy
の定義が変更された。
| template<class U>
void destroy(U* p);
|
メンバ関数 address
に条件式なしの noexcept
指定が付与され、例外を投げないことが保証された。
<memory> その他 †
下記のクラステンプレートが定義された。
| template<class T> class default_delete;
template<class T> class default_delete<T[]>;
|
| template<class T> class shared_ptr;
|
| template<class T, class Deleter = default_delete<T>> class unique_ptr;
template<class T, class Deleter> class unique_ptr<T[], Deleter>;
|
| template<class T> class weak_ptr;
|
| template<class T> class enable_shared_from_this;
|
| template<class Ptr> struct owner_less; template<class T> struct owner_less<shared_ptr<T>>;
template<class T> struct owner_less<weak_ptr<T>>;
|
| template<class Ptr> class pointer_traits;
template<class T> class pointer_traits<T*>;
|
| template<class Alloc> struct allocator_traits;
|
| template<class T, class Alloc> struct uses_allocator;
|
下記のフリー関数が定義された。
| template<class T, class ...Args>
shared_ptr<T> make_shared(Args&&... args);
|
| template<class T, class Alloc, class ...Args>
shared_ptr<T> allocate_shared(const Alloc& alloc, Args&&... args);
|
| template<class T, class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& p) noexcept;
|
| template<class T, class U>
shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& p) noexcept;
|
| template<class T, class U>
shared_ptr<T> const_pointer_cast(const shared_ptr<U>& p) noexcept;
|
| template<class Deleter, class T>
Deleter* get_deleter(const shared_ptr<T>& p) noexcept;
|
| template<class T> T* addressof(T& value) noexcept;
|
| void* align(size_t alignment, size_t size, void*& p, size_t& space);
|
| template<class InputIterator, class Size, class ForwardIterator>
ForwardIterator uninitialized_copy_n(
InputIterator first,
Size size,
ForwardIterator result);
|
| enum class pointer_safety
{
relaxed, preferred, strict, };
pointer_safety get_pointer_safety() noexcept;
|
| void declare_reachable(void* p);
template<class T> T* undeclare_reachable(T* p);
void declare_no_pointers(char* p, size_t size);
void undeclare_no_pointers(char* p, size_t size);
|
定数 allocator_arg
とその型 allocator_arg_t
が定義された。
@code{tuple} や function
等のコンストラクタでアロケータを指定する場合に、他のコンストラクタオーバロードとの曖昧さを回避するために第1引数に指定する。
フリー関数 get_temporary_buffer
に条件式なしの noexcept
指定が付与され、例外を投げないことが保証された。
フリー関数 uninitialized_fill_n
の定義が変更され、コピーの終端位置を指すイテレータを返すようになった。
クラステンプレート auto_ptr
が非推奨となった。
<new> †
<stdexcept> †
<typeinfo> †
type_info クラス †
<utility> †
pair クラステンプレート †
<utility> その他 †
下記のクラステンプレートが定義された。
| template<size_t I, class Pair> class tuple_element; template<class T1, class T2> struct tuple_element<0, pair<T1, T2>>;
template<class T1, class T2> struct tuple_element<1, pair<T1, T2>>;
|
| template<class Pair> class tuple_size; template<class T1, class T2> struct tuple_size<pair<T1, T2>>;
|
下記のフリー関数が定義された。
| template<size_t I, class T1, class T2>
typename tuple_element<I, pair<T1, T2>>::type& get(pair<T1, T2>& p) noexcept;
template<size_t I, class T1, class T2>
const typename tuple_element<I, pair<T1, T2>>::type& get(
const pair<T1, T2>& p) noexcept;
template<size_t I, class T1, class T2>
typename tuple_element<I, pair<T1, T2>>::type&& get(pair<T1, T2>&& p) noexcept;
|
| template<class T> typename remove_reference<T>::type&& move(T&& value) noexcept;
|
| template<class T>
typename conditional<
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
const T&,
T&&>::type
move_if_noexcept(T& value) noexcept;
|
| template<class T> T&& forward(typename remove_reference<T>::type& value) noexcept;
template<class T> T&& forward(typename remove_reference<T>::type&& value) noexcept;
|
| template<class T> typename add_rvalue_reference<T>::type declval() noexcept;
|
定数 piecewise_construct
とその型 piecewise_construct_t
が定義された。
pair
クラステンプレートの新しいコンストラクタで第1引数に渡す。
フリー関数 swap
が <algorithm> から移動され、定義が変更された。
| template<class T> void swap(T& a, T& b);
|
|
template<class T> void swap(T& a, T& b)
noexcept(
is_nothrow_move_constructible<T>::value &&
is_nothrow_move_assignable<T>::value);
template<class T, size_t N> void swap(T (&a)[N], T (&b)[N])
noexcept(noexcept(swap(*a, *b)));
|
フリー関数 swap
の pair
クラステンプレート用オーバロードが定義された。
| template<class T1, class T2>
void swap(pair<T1, T2>& a, pair<T1, T2>& b) noexcept(noexcept(a.swap(b)));
|
フリー関数 make_pair
の定義が変更された。
| template<class T1, class T2>
pair<T1, T2> make_pair(T1 first, T2 second);
|
| template<class T1, class T2>
pair<R1, R2> make_pair(T1&& first, T2&& second);
|
上記の型 R1
および R2
は、引数の型 T1
および T2
から下記のように定まる。(参考コンパイラ:gcc-4.8.1)
| template<class T> __strip_reference_wrapper { typedef T type; }
template<class T>
__strip_reference_wrapper<reference_wrapper<T>> { typedef T& type; }
template<class T>
__strip_reference_wrapper<const reference_wrapper<T>> { typedef T& type; }
typedef typename __strip_reference_wrapper<typename decay<T1>::type>::type R1;
typedef typename __strip_reference_wrapper<typename decay<T2>::type>::type R2;
|