Commit 250f5b6c by Ville Voutilainen Committed by Ville Voutilainen

Implement LWG 2900, The copy and move constructors of optional are not constexpr.

Implement LWG 2900, The copy and move constructors
of optional are not constexpr.
* include/std/optional (_Optional_payload): New.
(_Optional_base): Remove the bool parameter.
(_Optional_base<_Tp, false>): Remove.
(_Optional_base()): Adjust.
(_Optional_base(nullopt_t)): Likewise.
(_Optional_base(in_place_t, _Args&&...)): Likewise.
(_Optional_base(in_place_t, initializer_list<_Up>, _Args&&...)):
Likewise.
(_Optional_base(const _Optional_base&)): Likewise.
(_Optional_base(_Optional_base&&)): Likewise.
(operator=(const _Optional_base&)): Likewise.
(operator=(_Optional_base&&)): Likewise.
(~_Optional_base()): Remove.
(_M_is_engaged()): Adjust.
(_M_get()): Likewise.
(_M_construct(_Args&&...)): Likewise.
(_M_destruct()): Likewise.
(_M_reset()): Likewise.
(_Optional_base::_Empty_byte): Remove.
(_Optional_base::_M_empty): Remove.
(_Optional_base::_M_payload): Adjust.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust.
* testsuite/20_util/optional/constexpr/cons/value.cc: Add tests.

From-SVN: r246556
parent 19846619
2017-03-29 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement LWG 2900, The copy and move constructors
of optional are not constexpr.
* include/std/optional (_Optional_payload): New.
(_Optional_base): Remove the bool parameter.
(_Optional_base<_Tp, false>): Remove.
(_Optional_base()): Adjust.
(_Optional_base(nullopt_t)): Likewise.
(_Optional_base(in_place_t, _Args&&...)): Likewise.
(_Optional_base(in_place_t, initializer_list<_Up>, _Args&&...)):
Likewise.
(_Optional_base(const _Optional_base&)): Likewise.
(_Optional_base(_Optional_base&&)): Likewise.
(operator=(const _Optional_base&)): Likewise.
(operator=(_Optional_base&&)): Likewise.
(~_Optional_base()): Remove.
(_M_is_engaged()): Adjust.
(_M_get()): Likewise.
(_M_construct(_Args&&...)): Likewise.
(_M_destruct()): Likewise.
(_M_reset()): Likewise.
(_Optional_base::_Empty_byte): Remove.
(_Optional_base::_M_empty): Remove.
(_Optional_base::_M_payload): Adjust.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust.
* testsuite/20_util/optional/constexpr/cons/value.cc: Add tests.
2017-03-28 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/80137
......
......@@ -37,8 +37,8 @@ int main()
std::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" }
struct U { explicit U(std::in_place_t); };
std::optional<U> ou(std::in_place); // { dg-error "no matching" }
// { dg-error "no type" "" { target { *-*-* } } 437 }
// { dg-error "no type" "" { target { *-*-* } } 447 }
// { dg-error "no type" "" { target { *-*-* } } 504 }
// { dg-error "no type" "" { target { *-*-* } } 488 }
// { dg-error "no type" "" { target { *-*-* } } 498 }
// { dg-error "no type" "" { target { *-*-* } } 555 }
}
}
......@@ -66,4 +66,21 @@ int main()
static_assert( o, "" );
static_assert( *o == 0x1234ABCD, "" );
}
{
constexpr std::optional<long> o = 42;
constexpr std::optional<long> o2{o};
constexpr std::optional<long> o3(o);
constexpr std::optional<long> o4 = o;
constexpr std::optional<long> o5;
constexpr std::optional<long> o6{o5};
constexpr std::optional<long> o7(o5);
constexpr std::optional<long> o8 = o5;
constexpr std::optional<long> o9{std::move(o)};
constexpr std::optional<long> o10(std::move(o));
constexpr std::optional<long> o11 = std::move(o);
constexpr std::optional<long> o12;
constexpr std::optional<long> o13{std::move(o5)};
constexpr std::optional<long> o14(std::move(o5));
constexpr std::optional<long> o15 = std::move(o5);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment