class to represent optional objects (Revision 1) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1878.htm N3406 A proposal to add a utility class to represent optional objects (Revision 2) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3406.html N3527 A proposal to add a utility class to represent optional objects (Revision 3) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3527.html N3672 A proposal to add a utility class to represent optional objects (Revision 4) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3672.html N3765 On Optional http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3765.pdf N3793 A proposal to add a utility class to represent optional objects (Revision 5) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3793.html N3966 Fixes for optional objects http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3966.html N3982 Rvalue reference overloads for optional http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3982.html
Homogeneous interface for variant, any and optional http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0032r0.pdf P0032R1 Homogeneous interface for variant, any and optional (Revision 1) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0032r1.pdf P0032R2 Homogeneous interface for variant , any and optional (Revision 2) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0032r2.pdf P0307R0 Making Optional Greater Equal Again http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0307r0.pdf P0032R3 Homogeneous interface for variant, any and optional (Revision 3) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0032r3.pdf P0307R2 Making Optional Greater Equal Again http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0307r2.pdf P0504R0 Revisiting in-place tag types for any/optional/variant http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0504r0.html
42; }; auto v = std::make_optional<S>(); auto i = v->m; // メンバの値が取得されて i は 42 になる v->m = 99; // ポインタ経由なので更新もできる(こわい v = std::nullopt; auto j = v->m; // ダメ。ゼッタイ。(UB)
std::optional w = 3.14; // double auto b1 = v < w; // 普通に比較できて false になる auto b2 = v == 42.0; // 普通に比較できて true になる v = std::nullopt; auto b3 = v <= w; // 値無しは値有より小さいので // true になる auto b4 = v == std::nullopt; // 値無し同士で true になる