More of N4258 implementation. Mark all of our test_allocators as noexcept constructible. Make the constructors for basic_string noexcept all the time (under C++14). Update tests to reflect the new world order. More to come.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238957 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2015-06-03 19:56:43 +00:00
parent bbf87b1c34
commit 7b193f7797
8 changed files with 113 additions and 29 deletions

View File

@@ -14,6 +14,7 @@
#include <string>
#include <cassert>
#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
@@ -22,6 +23,11 @@ void
test()
{
{
#if TEST_STD_VER > 14
static_assert((noexcept(S{})), "" );
#elif TEST_STD_VER >= 11
static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
#endif
S s;
assert(s.__invariants());
assert(s.data());
@@ -30,6 +36,11 @@ test()
assert(s.get_allocator() == typename S::allocator_type());
}
{
#if TEST_STD_VER > 14
static_assert((noexcept(S{typename S::allocator_type{}})), "" );
#elif TEST_STD_VER >= 11
static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
#endif
S s(typename S::allocator_type(5));
assert(s.__invariants());
assert(s.data());
@@ -39,13 +50,18 @@ test()
}
}
#if __cplusplus >= 201103L
#if TEST_STD_VER >= 11
template <class S>
void
test2()
{
{
#if TEST_STD_VER > 14
static_assert((noexcept(S{})), "" );
#elif TEST_STD_VER >= 11
static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
#endif
S s;
assert(s.__invariants());
assert(s.data());
@@ -54,6 +70,11 @@ test2()
assert(s.get_allocator() == typename S::allocator_type());
}
{
#if TEST_STD_VER > 14
static_assert((noexcept(S{typename S::allocator_type{}})), "" );
#elif TEST_STD_VER >= 11
static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
#endif
S s(typename S::allocator_type{});
assert(s.__invariants());
assert(s.data());
@@ -68,7 +89,7 @@ test2()
int main()
{
test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
#if __cplusplus >= 201103L
#if TEST_STD_VER >= 11
test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
}