SlideShare a Scribd company logo
C++14 LWG.2193
explicitなデフォルトコンストラクタをなくす
高橋 晶(Akira Takahashi)
faithandbrave@longgate.co.jp
2014/06/27(金) WG21 C++14 DISレビュー会議
まえがき
• この資料は、C++14に取り入れられる予定の変更、LWG
(Library Working Group)のIssue 2194のレビューです。
• 2193. Default constructors for standard library
containers are explicit
• http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-
active.html#2193
概要
• explicit Container(Allocator alloc = Allocator());
• となっているデフォルトコンストラクタを、

以下のように分割する:
• Container() : Container(Allocator()) {}
• explicit Container(Allocator alloc);
元々の問題
• 以下のコードが不適格になっていた:
std::set<int> s = {}; // エラー!explicitが付いている
• このコードはClang 3.0でコンパイルエラーになっていた。
• この問題を解決するために、前述した解決策が提示されたが、
実際にはこの問題はEWG (Evolution Working Group)側で
処理された。
• そのためこのIssueでの解決策は、気持ち悪さの解消程度。
変更対象
• basic_string
• deque
• forward_list
• list
• vector
• (multi)map
• (multi)set
• unordered_(multi)map
• unordered_(multi)set
ABIが壊れないか調査した
• オーバーロードの追加は、ABIを壊さない。
• デフォルト引数の追加・削除は、ABIを壊さない。
• よって、この変更はABIを壊さない。
• C++11でstd::vectorのresize()メンバ関数に以下の変更が
入ったが、その変更はABIを壊さなかった。
• void resize(size_type sz, T c = T());
• void resize(size_type sz);
• void resize(size_type sz, const T& c);
参照
• ABI Policy and Guidelines - libstdc++
• http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
• Cxx11AbiCompatibility - GCC Wiki
• http://gcc.gnu.org/wiki/Cxx11AbiCompatibility
• Thiago Macieira: Binary compatibility for library developers
• https://github.com/boostcon/cppnow_presentations_2013/blob/
master/tue/binary_compat_for_cpp_devs.pdf?raw=true

More Related Content

KEY
Cost of ovs receiving process
PPTX
ParliamentでGeoSPARQL
PPTX
Distributed processwithapex&amp;flow lowcode
PDF
RestKitの紹介 - Webサービスのクライアント実装補助フレームワーク -
PPTX
Wpfと非同期
PPTX
Kubernetesできること
PDF
Introduction to boost test
PPTX
Pub/Sub model, msm, and asio
Cost of ovs receiving process
ParliamentでGeoSPARQL
Distributed processwithapex&amp;flow lowcode
RestKitの紹介 - Webサービスのクライアント実装補助フレームワーク -
Wpfと非同期
Kubernetesできること
Introduction to boost test
Pub/Sub model, msm, and asio

More from Akira Takahashi (20)

PPTX
Cpp20 overview language features
PDF
Cppmix 02
PPTX
Cppmix 01
PDF
Modern C++ Learning
PDF
cpprefjp documentation
PDF
C++1z draft
PDF
Boost tour 1_61_0 merge
PDF
Boost tour 1_61_0
PDF
error handling using expected
PDF
Boost tour 1.60.0 merge
PDF
Boost tour 1.60.0
PDF
Boost container feature
PDF
Boost Tour 1_58_0 merge
PDF
Boost Tour 1_58_0
PDF
C++14 enum hash
PDF
Multi paradigm design
PDF
Start Concurrent
PDF
Programmer mind
PDF
Boost.Study 14 Opening
PDF
Executors and schedulers
Cpp20 overview language features
Cppmix 02
Cppmix 01
Modern C++ Learning
cpprefjp documentation
C++1z draft
Boost tour 1_61_0 merge
Boost tour 1_61_0
error handling using expected
Boost tour 1.60.0 merge
Boost tour 1.60.0
Boost container feature
Boost Tour 1_58_0 merge
Boost Tour 1_58_0
C++14 enum hash
Multi paradigm design
Start Concurrent
Programmer mind
Boost.Study 14 Opening
Executors and schedulers
Ad

C++14 solve explicit_default_constructor