More N4258 changes. This time vector's constructors
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238990 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7b193f7797
commit
127db91f3e
@ -501,13 +501,22 @@ public:
|
|||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
vector()
|
vector()
|
||||||
|
#if _LIBCPP_STD_VER <= 14
|
||||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||||
|
#else
|
||||||
|
_NOEXCEPT
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
__get_db()->__insert_c(this);
|
__get_db()->__insert_c(this);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
|
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
|
||||||
|
#if _LIBCPP_STD_VER <= 14
|
||||||
|
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
|
||||||
|
#else
|
||||||
|
_NOEXCEPT
|
||||||
|
#endif
|
||||||
: __base(__a)
|
: __base(__a)
|
||||||
{
|
{
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
@ -2162,8 +2171,18 @@ private:
|
|||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
vector()
|
vector()
|
||||||
|
#if _LIBCPP_STD_VER <= 14
|
||||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
|
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
|
||||||
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a);
|
#else
|
||||||
|
_NOEXCEPT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
|
||||||
|
#if _LIBCPP_STD_VER <= 14
|
||||||
|
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
|
||||||
|
#else
|
||||||
|
_NOEXCEPT;
|
||||||
|
#endif
|
||||||
~vector();
|
~vector();
|
||||||
explicit vector(size_type __n);
|
explicit vector(size_type __n);
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
@ -2550,7 +2569,11 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
|
|||||||
template <class _Allocator>
|
template <class _Allocator>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
vector<bool, _Allocator>::vector()
|
vector<bool, _Allocator>::vector()
|
||||||
|
#if _LIBCPP_STD_VER <= 14
|
||||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||||
|
#else
|
||||||
|
_NOEXCEPT
|
||||||
|
#endif
|
||||||
: __begin_(nullptr),
|
: __begin_(nullptr),
|
||||||
__size_(0),
|
__size_(0),
|
||||||
__cap_alloc_(0)
|
__cap_alloc_(0)
|
||||||
@ -2560,6 +2583,11 @@ vector<bool, _Allocator>::vector()
|
|||||||
template <class _Allocator>
|
template <class _Allocator>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
vector<bool, _Allocator>::vector(const allocator_type& __a)
|
vector<bool, _Allocator>::vector(const allocator_type& __a)
|
||||||
|
#if _LIBCPP_STD_VER <= 14
|
||||||
|
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
|
||||||
|
#else
|
||||||
|
_NOEXCEPT
|
||||||
|
#endif
|
||||||
: __begin_(nullptr),
|
: __begin_(nullptr),
|
||||||
__size_(0),
|
__size_(0),
|
||||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
@ -22,11 +23,16 @@ template <class C>
|
|||||||
void
|
void
|
||||||
test0()
|
test0()
|
||||||
{
|
{
|
||||||
|
#if TEST_STD_VER > 14
|
||||||
|
static_assert((noexcept(C{})), "" );
|
||||||
|
#elif TEST_STD_VER >= 11
|
||||||
|
static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
|
||||||
|
#endif
|
||||||
C c;
|
C c;
|
||||||
assert(c.__invariants());
|
assert(c.__invariants());
|
||||||
assert(c.empty());
|
assert(c.empty());
|
||||||
assert(c.get_allocator() == typename C::allocator_type());
|
assert(c.get_allocator() == typename C::allocator_type());
|
||||||
#if __cplusplus >= 201103L
|
#if TEST_STD_VER >= 11
|
||||||
C c1 = {};
|
C c1 = {};
|
||||||
assert(c1.__invariants());
|
assert(c1.__invariants());
|
||||||
assert(c1.empty());
|
assert(c1.empty());
|
||||||
@ -38,6 +44,11 @@ template <class C>
|
|||||||
void
|
void
|
||||||
test1(const typename C::allocator_type& a)
|
test1(const typename C::allocator_type& a)
|
||||||
{
|
{
|
||||||
|
#if TEST_STD_VER > 14
|
||||||
|
static_assert((noexcept(C{typename C::allocator_type{}})), "" );
|
||||||
|
#elif TEST_STD_VER >= 11
|
||||||
|
static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
|
||||||
|
#endif
|
||||||
C c(a);
|
C c(a);
|
||||||
assert(c.__invariants());
|
assert(c.__invariants());
|
||||||
assert(c.empty());
|
assert(c.empty());
|
||||||
@ -50,7 +61,7 @@ int main()
|
|||||||
test0<std::vector<bool> >();
|
test0<std::vector<bool> >();
|
||||||
test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
|
test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if TEST_STD_VER >= 11
|
||||||
{
|
{
|
||||||
test0<std::vector<bool, min_allocator<bool>> >();
|
test0<std::vector<bool, min_allocator<bool>> >();
|
||||||
test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
|
test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
|
||||||
|
@ -39,11 +39,21 @@ int main()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef std::vector<bool, other_allocator<bool>> C;
|
typedef std::vector<bool, other_allocator<bool>> C;
|
||||||
|
// See N4258 - vector<T, Allocator>::basic_string() noexcept;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#else
|
||||||
|
static_assert( std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef std::vector<bool, some_alloc<bool>> C;
|
typedef std::vector<bool, some_alloc<bool>> C;
|
||||||
|
// See N4258 - vector<T, Allocator>::basic_string() noexcept;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#else
|
||||||
|
static_assert( std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
// <vector>
|
// <vector>
|
||||||
|
|
||||||
// vector(const Alloc& = Alloc());
|
// vector();
|
||||||
|
// vector(const Alloc&);
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -24,12 +25,17 @@ template <class C>
|
|||||||
void
|
void
|
||||||
test0()
|
test0()
|
||||||
{
|
{
|
||||||
|
#if TEST_STD_VER > 14
|
||||||
|
static_assert((noexcept(C{})), "" );
|
||||||
|
#elif TEST_STD_VER >= 11
|
||||||
|
static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" );
|
||||||
|
#endif
|
||||||
C c;
|
C c;
|
||||||
assert(c.__invariants());
|
assert(c.__invariants());
|
||||||
assert(c.empty());
|
assert(c.empty());
|
||||||
assert(c.get_allocator() == typename C::allocator_type());
|
assert(c.get_allocator() == typename C::allocator_type());
|
||||||
assert(is_contiguous_container_asan_correct(c));
|
assert(is_contiguous_container_asan_correct(c));
|
||||||
#if __cplusplus >= 201103L
|
#if TEST_STD_VER >= 11
|
||||||
C c1 = {};
|
C c1 = {};
|
||||||
assert(c1.__invariants());
|
assert(c1.__invariants());
|
||||||
assert(c1.empty());
|
assert(c1.empty());
|
||||||
@ -42,6 +48,11 @@ template <class C>
|
|||||||
void
|
void
|
||||||
test1(const typename C::allocator_type& a)
|
test1(const typename C::allocator_type& a)
|
||||||
{
|
{
|
||||||
|
#if TEST_STD_VER > 14
|
||||||
|
static_assert((noexcept(C{typename C::allocator_type{}})), "" );
|
||||||
|
#elif TEST_STD_VER >= 11
|
||||||
|
static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" );
|
||||||
|
#endif
|
||||||
C c(a);
|
C c(a);
|
||||||
assert(c.__invariants());
|
assert(c.__invariants());
|
||||||
assert(c.empty());
|
assert(c.empty());
|
||||||
@ -62,7 +73,7 @@ int main()
|
|||||||
std::vector<int, stack_allocator<int, 10> > v;
|
std::vector<int, stack_allocator<int, 10> > v;
|
||||||
assert(v.empty());
|
assert(v.empty());
|
||||||
}
|
}
|
||||||
#if __cplusplus >= 201103L
|
#if TEST_STD_VER >= 11
|
||||||
{
|
{
|
||||||
test0<std::vector<int, min_allocator<int>> >();
|
test0<std::vector<int, min_allocator<int>> >();
|
||||||
test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
|
test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "MoveOnly.h"
|
#include "MoveOnly.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
|
|
||||||
@ -40,11 +41,21 @@ int main()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
|
typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
|
||||||
|
// See N4258 - vector<T, Allocator>::basic_string() noexcept;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#else
|
||||||
|
static_assert( std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
|
typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
|
||||||
|
// See N4258 - vector<T, Allocator>::basic_string() noexcept;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#else
|
||||||
|
static_assert( std::is_nothrow_default_constructible<C>::value, "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user