Commit 9057edd3 by Jonathan Wakely Committed by Jonathan Wakely

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
parent 7574e458
2017-05-08 Jonathan Wakely <jwakely@redhat.com> 2017-05-08 Jonathan Wakely <jwakely@redhat.com>
* 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/xml/manual/mt_allocator.xml: Clarify deallocation behaviour.
* doc/html/*: Regenerate. * doc/html/*: Regenerate.
......
...@@ -462,10 +462,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -462,10 +462,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Unique tag type. // Unique tag type.
optional<_Tp>> optional<_Tp>>
{ {
static_assert(__and_<__not_<is_same<remove_cv_t<_Tp>, nullopt_t>>, static_assert(!is_same_v<remove_cv_t<_Tp>, nullopt_t>);
__not_<is_same<remove_cv_t<_Tp>, in_place_t>>, static_assert(!is_same_v<remove_cv_t<_Tp>, in_place_t>);
__not_<is_reference<_Tp>>>(), static_assert(!is_reference_v<_Tp>);
"Invalid instantiation of optional<T>");
private: private:
using _Base = _Optional_base<_Tp>; using _Base = _Optional_base<_Tp>;
...@@ -756,9 +755,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -756,9 +755,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr _Tp constexpr _Tp
value_or(_Up&& __u) const& value_or(_Up&& __u) const&
{ {
static_assert(__and_<is_copy_constructible<_Tp>, static_assert(is_copy_constructible_v<_Tp>);
is_convertible<_Up&&, _Tp>>(), static_assert(is_convertible_v<_Up&&, _Tp>);
"Cannot return value");
return this->_M_is_engaged() return this->_M_is_engaged()
? this->_M_get() ? this->_M_get()
...@@ -769,9 +767,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -769,9 +767,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Tp _Tp
value_or(_Up&& __u) && value_or(_Up&& __u) &&
{ {
static_assert(__and_<is_move_constructible<_Tp>, static_assert(is_move_constructible_v<_Tp>);
is_convertible<_Up&&, _Tp>>(), static_assert(is_convertible_v<_Up&&, _Tp>);
"Cannot return value" );
return this->_M_is_engaged() return this->_M_is_engaged()
? std::move(this->_M_get()) ? std::move(this->_M_get())
......
...@@ -37,8 +37,8 @@ int main() ...@@ -37,8 +37,8 @@ int main()
std::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" } std::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" }
struct U { explicit U(std::in_place_t); }; struct U { explicit U(std::in_place_t); };
std::optional<U> ou(std::in_place); // { dg-error "no matching" } std::optional<U> ou(std::in_place); // { dg-error "no matching" }
// { dg-error "no type" "" { target { *-*-* } } 488 } // { dg-error "no type" "" { target { *-*-* } } 487 }
// { dg-error "no type" "" { target { *-*-* } } 498 } // { dg-error "no type" "" { target { *-*-* } } 497 }
// { dg-error "no type" "" { target { *-*-* } } 555 } // { dg-error "no type" "" { target { *-*-* } } 554 }
} }
} }
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