From 4beeba5420d73c70a838f3f0bbd7e9006e997e5a Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Mon, 8 Jun 2015 23:37:40 +0200 Subject: [PATCH] msvc noexcept test improvement --- test/ak_test_vc14_noexcept.cpp | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/ak_test_vc14_noexcept.cpp b/test/ak_test_vc14_noexcept.cpp index f6ab367..03aa15a 100644 --- a/test/ak_test_vc14_noexcept.cpp +++ b/test/ak_test_vc14_noexcept.cpp @@ -23,6 +23,45 @@ using boost::optional; BOOST_STATIC_ASSERT_MSG(false, "absent noexcept"); #endif +// these 4 classes have different noexcept signatures in move operations +struct NothrowBoth { + NothrowBoth() BOOST_NOEXCEPT {}; + NothrowBoth(NothrowBoth&&) BOOST_NOEXCEPT_IF(true) {}; + void operator=(NothrowBoth&&) BOOST_NOEXCEPT_IF(true) {}; +}; +struct NothrowCtor { + NothrowCtor(NothrowCtor&&) BOOST_NOEXCEPT_IF(true) {}; + void operator=(NothrowCtor&&) BOOST_NOEXCEPT_IF(false) {}; +}; +struct NothrowAssign { + NothrowAssign(NothrowAssign&&) BOOST_NOEXCEPT_IF(false) {}; + void operator=(NothrowAssign&&) BOOST_NOEXCEPT_IF(true) {}; +}; +struct NothrowNone { + NothrowNone(NothrowNone&&) BOOST_NOEXCEPT_IF(false) {}; + void operator=(NothrowNone&&) BOOST_NOEXCEPT_IF(false) {}; +}; + +NothrowBoth ntb; +BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ntb = NothrowBoth() )); + +void test_noexcept_as_defined() // this is a compile-time test +{ + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable::value); + + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable::value); + + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable::value); + + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable::value); +} + + + int main() { return 0;