static const size_type npos = -1;
_LIBCPP_INLINE_VISIBILITY basic_string()
+#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a);
+#else
+ _NOEXCEPT;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
+#else
+ _NOEXCEPT;
+#endif
+
basic_string(const basic_string& __str);
basic_string(const basic_string& __str, const allocator_type& __a);
+
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
basic_string(basic_string&& __str)
+#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+#else
+ _NOEXCEPT;
+#endif
+
_LIBCPP_INLINE_VISIBILITY
basic_string(basic_string&& __str, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>::basic_string()
- _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+#if _LIBCPP_STD_VER <= 14
+ _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
+#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+#else
+ _NOEXCEPT
+#endif
: __r_(_VSTD::move(__str.__r_))
{
__str.__zero();
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
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());
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());
}
}
-#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());
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());
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
}
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "test_allocator.h"
template <class T>
}
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+// See N4258 - basic_string<char, traits, Allocator>::basic_string() noexcept;
+#if TEST_STD_VER <= 14
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+#else
+ static_assert( std::is_nothrow_default_constructible<C>::value, "");
+#endif
}
#endif
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+// #if _LIBCPP_STD_VER <= 14
+// _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+// #else
+// _NOEXCEPT;
+// #endif
int main()
{
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" );
+#endif
test(S(), A(3));
test(S("1"), A(5));
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" );
+#endif
S s1 ( "Twas brillig, and the slivy toves did gyre and gymbal in the wabe" );
S s2 (std::move(s1), A(1));
}
assert ( test_alloc_base::alloc_count == alloc_count );
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef min_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
+#if TEST_STD_VER > 14
+ static_assert((noexcept(S{})), "" );
+#elif TEST_STD_VER >= 11
+ static_assert((noexcept(S()) == std::is_nothrow_move_constructible<A>::value), "" );
+#endif
test(S(), A());
test(S("1"), A());
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "test_allocator.h"
template <class T>
}
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+#if TEST_STD_VER <= 14
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+#else
+ static_assert( std::is_nothrow_move_constructible<C>::value, "");
+#endif
}
#endif
}
#include <type_traits>
#include <utility>
+#include "test_macros.h"
+
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class T>
{
int id_;
public:
- explicit A1(int id = 0) : id_(id) {}
+ explicit A1(int id = 0) TEST_NOEXCEPT : id_(id) {}
typedef T value_type;
static bool allocate_called;
static std::pair<T*, std::size_t> deallocate_called;
- A1(const A1& a) : id_(a.id()) {copy_called = true;}
- A1(A1&& a) : id_(a.id()) {move_called = true;}
+ A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ A1(A1&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;}
template <class U>
- A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
+ A1(const A1<U>& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
template <class U>
- A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
+ A1(A1<U>&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;}
T* allocate(std::size_t n)
{
{
int id_;
public:
- explicit A2(int id = 0) : id_(id) {}
+ explicit A2(int id = 0) TEST_NOEXCEPT : id_(id) {}
typedef T value_type;
static bool move_called;
static bool allocate_called;
- A2(const A2& a) : id_(a.id()) {copy_called = true;}
- A2(A2&& a) : id_(a.id()) {move_called = true;}
+ A2(const A2& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ A2(A2&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;}
T* allocate(std::size_t n, const void* hint)
{
{
int id_;
public:
- explicit A3(int id = 0) : id_(id) {}
+ explicit A3(int id = 0) TEST_NOEXCEPT : id_(id) {}
typedef T value_type;
static bool constructed;
static bool destroy_called;
- A3(const A3& a) : id_(a.id()) {copy_called = true;}
- A3(A3&& a) : id_(a.id()) {move_called = true;}
+ A3(const A3& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;}
+ A3(A3&& a) TEST_NOEXCEPT: id_(a.id()) {move_called = true;}
template <class U, class ...Args>
void construct(U* p, Args&& ...args)
#include <cstddef>
+#include "test_macros.h"
+
template <class T>
class bare_allocator
{
public:
typedef T value_type;
- bare_allocator() {}
+ bare_allocator() TEST_NOEXCEPT {}
template <class U>
- bare_allocator(bare_allocator<U>) {}
+ bare_allocator(bare_allocator<U>) TEST_NOEXCEPT {}
T* allocate(std::size_t n)
{
{
const void* ptr_;
public:
- min_pointer() noexcept = default;
- min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
template <class T>
- min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
+ min_pointer(min_pointer<T> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
explicit operator bool() const {return ptr_ != nullptr;}
{
void* ptr_;
public:
- min_pointer() noexcept = default;
- min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
template <class T,
class = typename std::enable_if
<
!std::is_const<T>::value
>::type
>
- min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
+ min_pointer(min_pointer<T> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
explicit operator bool() const {return ptr_ != nullptr;}
{
T* ptr_;
- explicit min_pointer(T* p) : ptr_(p) {}
+ explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
public:
- min_pointer() noexcept = default;
- min_pointer(std::nullptr_t) : ptr_(nullptr) {}
- explicit min_pointer(min_pointer<void> p) : ptr_(static_cast<T*>(p.ptr_)) {}
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ explicit min_pointer(min_pointer<void> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
explicit operator bool() const {return ptr_ != nullptr;}
explicit min_pointer(const T* p) : ptr_(p) {}
public:
- min_pointer() noexcept = default;
+ min_pointer() TEST_NOEXCEPT = default;
min_pointer(std::nullptr_t) : ptr_(nullptr) {}
min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
explicit min_pointer(min_pointer<const void> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
#include <climits>
#include <cassert>
+#include "test_macros.h"
+
class test_alloc_base
{
protected: