From: Jonathan Wakely Date: Mon, 8 May 2017 17:13:38 +0000 (+0100) Subject: Tweak static assertions in std::optional X-Git-Tag: upstream/12.2.0~39686 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9057edd30c40ea77707650699f38734eb949b7d6;p=platform%2Fupstream%2Fgcc.git Tweak static assertions in std::optional * include/std/optional: Use a separate static_assert per condition. * testsuite/20_util/optional/cons/value_neg.cc: Update dg-error line numbers. From-SVN: r247748 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b5a6719..f285939 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2017-05-08 Jonathan Wakely + * include/std/optional: Use a separate static_assert per condition. + * testsuite/20_util/optional/cons/value_neg.cc: Update dg-error line + numbers. + * doc/xml/manual/mt_allocator.xml: Clarify deallocation behaviour. * doc/html/*: Regenerate. diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 1724120..5aa926f 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -462,10 +462,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Unique tag type. optional<_Tp>> { - static_assert(__and_<__not_, nullopt_t>>, - __not_, in_place_t>>, - __not_>>(), - "Invalid instantiation of optional"); + static_assert(!is_same_v, nullopt_t>); + static_assert(!is_same_v, in_place_t>); + static_assert(!is_reference_v<_Tp>); private: using _Base = _Optional_base<_Tp>; @@ -756,9 +755,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr _Tp value_or(_Up&& __u) const& { - static_assert(__and_, - is_convertible<_Up&&, _Tp>>(), - "Cannot return value"); + static_assert(is_copy_constructible_v<_Tp>); + static_assert(is_convertible_v<_Up&&, _Tp>); return this->_M_is_engaged() ? this->_M_get() @@ -769,9 +767,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp value_or(_Up&& __u) && { - static_assert(__and_, - is_convertible<_Up&&, _Tp>>(), - "Cannot return value" ); + static_assert(is_move_constructible_v<_Tp>); + static_assert(is_convertible_v<_Up&&, _Tp>); return this->_M_is_engaged() ? std::move(this->_M_get()) diff --git a/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc b/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc index 87907f9..5abe26e 100644 --- a/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc +++ b/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc @@ -37,8 +37,8 @@ int main() std::optional> oup2 = new int; // { dg-error "conversion" } struct U { explicit U(std::in_place_t); }; std::optional ou(std::in_place); // { dg-error "no matching" } - // { dg-error "no type" "" { target { *-*-* } } 488 } - // { dg-error "no type" "" { target { *-*-* } } 498 } - // { dg-error "no type" "" { target { *-*-* } } 555 } + // { dg-error "no type" "" { target { *-*-* } } 487 } + // { dg-error "no type" "" { target { *-*-* } } 497 } + // { dg-error "no type" "" { target { *-*-* } } 554 } } }