We require move semantics in C++03 anyways, so let's enable them for the containers.
Reviewed By: ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D123802
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef iterator_type pointer;
-#ifndef _LIBCPP_CXX03_LANG
typedef typename iterator_traits<iterator_type>::reference __reference;
typedef typename conditional<
is_reference<__reference>::value,
typename remove_reference<__reference>::type&&,
__reference
>::type reference;
-#else
- typedef typename iterator_traits<iterator_type>::reference reference;
-#endif
-
#endif // _LIBCPP_STD_VER > 17
#if _LIBCPP_STD_VER > 17
return static_cast<_Up&&>(__t);
}
-#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
using __move_if_noexcept_result_t =
typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
_Tp&&>::type;
-#else // _LIBCPP_CXX03_LANG
-template <class _Tp>
-using __move_if_noexcept_result_t = const _Tp&;
-#endif
template <class _Tp>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>
vector(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
+ vector& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+#endif // !_LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
- _NOEXCEPT;
+ noexcept;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- _LIBCPP_INLINE_VISIBILITY
- vector& operator=(initializer_list<value_type> __il)
- {assign(__il.begin(), __il.end()); return *this;}
-
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _InputIterator>
typename enable_if
<
const value_type* data() const _NOEXCEPT
{return _VSTD::__to_address(this->__begin_);}
-#ifdef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
- void __emplace_back(const value_type& __x) { push_back(__x); }
-#else
- template <class _Arg>
- _LIBCPP_INLINE_VISIBILITY
- void __emplace_back(_Arg&& __arg) {
- emplace_back(_VSTD::forward<_Arg>(__arg));
- }
-#endif
-
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14
reference emplace_back(_Args&&... __args);
#else
void emplace_back(_Args&&... __args);
#endif
-#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void pop_back();
iterator insert(const_iterator __position, const_reference __x);
-#ifndef _LIBCPP_CXX03_LANG
iterator insert(const_iterator __position, value_type&& __x);
template <class... _Args>
- iterator emplace(const_iterator __position, _Args&&... __args);
-#endif // !_LIBCPP_CXX03_LANG
+ iterator emplace(const_iterator __position, _Args&&... __args);
iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
__annotate_shrink(__old_size);
}
-#ifndef _LIBCPP_CXX03_LANG
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
inline void __push_back_slow_path(_Up&& __x);
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
inline void __emplace_back_slow_path(_Args&&... __args);
-#else
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- inline void __push_back_slow_path(_Up& __x);
-#endif
// The following functions are no-ops outside of AddressSanitizer mode.
// We call annotatations only for the default Allocator because other allocators
{
_VSTD::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
- __emplace_back(*__first);
+ emplace_back(*__first);
}
template <class _Tp, class _Allocator>
{
_VSTD::__debug_db_insert_c(this);
for (; __first != __last; ++__first)
- __emplace_back(*__first);
+ emplace_back(*__first);
}
template <class _Tp, class _Allocator>
}
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
- _NOEXCEPT
+ noexcept
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#endif
}
}
+#ifndef _LIBCPP_CXX03_LANG
+
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
}
}
+#endif // _LIBCPP_CXX03_LANG
+
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
std::__debug_db_swap(this, std::addressof(__c));
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
{
clear();
for (; __first != __last; ++__first)
- __emplace_back(*__first);
+ emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _Tp, class _Allocator>
template <class _Up>
void
-#ifndef _LIBCPP_CXX03_LANG
vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
-#else
-vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
-#endif
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
__push_back_slow_path(__x);
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
#endif
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
inline
void
return __make_iter(__p);
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
return __make_iter(__p);
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
vector(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
+ vector& operator=(initializer_list<value_type> __il)
+ {assign(__il.begin(), __il.end()); return *this;}
+
+#endif // !_LIBCPP_CXX03_LANG
+
+ _LIBCPP_INLINE_VISIBILITY
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
- _NOEXCEPT;
+ noexcept;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
- _LIBCPP_INLINE_VISIBILITY
- vector& operator=(initializer_list<value_type> __il)
- {assign(__il.begin(), __il.end()); return *this;}
-
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _InputIterator>
typename enable_if
<
return *this;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
__c.__cap() = __c.__size_ = 0;
}
-#endif // !_LIBCPP_CXX03_LANG
-
template <class _Allocator>
void
vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
{
MoveOnly mo[] = {MoveOnly{3}};
// expected-error@array:* {{to_array requires copy constructible elements}}
- // expected-error@array:* {{call to implicitly-deleted copy constructor of 'MoveOnly'}}
+ // expected-error-re@array:* {{{{(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
std::to_array(mo); // expected-note {{requested here}}
}
{
const MoveOnly cmo[] = {MoveOnly{3}};
// expected-error@array:* {{to_array requires move constructible elements}}
- // expected-error@array:* {{call to implicitly-deleted copy constructor of 'MoveOnly'}}
+ // expected-error-re@array:* {{{{(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
std::to_array(std::move(cmo)); // expected-note {{requested here}}
}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
assert(is_contiguous_container_asan_correct(l2));
}
{
- std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
- std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
- std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2((min_allocator<MoveOnly>()));
l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
// Make sure that a std::vector containing move-only types can't be copied.
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
#include <vector>
-struct move_only
-{
- move_only() = default;
- move_only(move_only&&) = default;
- move_only& operator=(move_only&&) = default;
-};
+#include "MoveOnly.h"
int main(int, char**)
{
- std::vector<move_only> v;
- std::vector<move_only> copy = v; // expected-error-re@* {{{{(no matching function for call to 'construct_at')|(call to implicitly-deleted copy constructor of 'move_only')}}}}
+ std::vector<MoveOnly> v;
+ std::vector<MoveOnly> copy = v; // expected-error-re@* {{{{(no matching function for call to 'construct_at')|(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
return 0;
}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
void test() {
{
- std::vector<operator_hijacker> vo{};
- std::vector<operator_hijacker> v{std::move(vo)};
+ std::vector<operator_hijacker> vo;
+ std::vector<operator_hijacker> v(std::move(vo));
}
{
- std::vector<operator_hijacker> vo{};
- std::vector<operator_hijacker> v{std::move(vo), std::allocator<operator_hijacker>{}};
+ std::vector<operator_hijacker> vo;
+ std::vector<operator_hijacker> v(std::move(vo), std::allocator<operator_hijacker>());
}
}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
assert(is_contiguous_container_asan_correct(c2));
}
{
- std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
- std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
}
{
int a1[] = {1, 3, 7, 9, 10};
- std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int> > c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
assert(is_contiguous_container_asan_correct(c1));
- std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
- std::vector<int, min_allocator<int>> c2 = std::move(c1);
+ std::vector<int, min_allocator<int> >::const_iterator i = c1.begin();
+ std::vector<int, min_allocator<int> > c2 = std::move(c1);
assert(is_contiguous_container_asan_correct(c2));
- std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
+ std::vector<int, min_allocator<int> >::iterator j = c2.erase(i);
assert(*j == 3);
assert(is_contiguous_container_asan_correct(c2));
}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
assert(is_contiguous_container_asan_correct(l2));
}
{
- std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
- std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
assert(is_contiguous_container_asan_correct(c));
}
{
- std::vector<A, min_allocator<A>> c;
- std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ std::vector<A, min_allocator<A> > c;
+ std::vector<A, min_allocator<A> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
assert(i == c.begin());
assert(c.size() == 1);
assert(c.front().geti() == 2);
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
int i_;
double d_;
- A(const A&);
- A& operator=(const A&);
public:
+ A(const A&) = delete;
+ A& operator=(const A&) = delete;
+
A(int i, double d)
: i_(i), d_(d) {}
assert(is_contiguous_container_asan_correct(c));
}
{
- std::vector<A, min_allocator<A>> c;
+ std::vector<A, min_allocator<A> > c;
#if TEST_STD_VER > 14
A& r1 = c.emplace_back(2, 3.5);
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
}
{
- std::vector<Tag_X, TaggingAllocator<Tag_X>> c;
+ std::vector<Tag_X, TaggingAllocator<Tag_X> > c;
c.emplace_back();
assert(c.size() == 1);
c.emplace_back(1, 2, 3);
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
void test() {
std::vector<operator_hijacker> v;
- v.insert(v.end(), operator_hijacker{});
+ v.insert(v.end(), operator_hijacker());
}
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
assert(v[j] == MoveOnly());
}
{
- std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
- std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > v(100);
+ std::vector<MoveOnly, min_allocator<MoveOnly> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
assert(c[j] == MoveOnly(j));
}
{
- std::vector<MoveOnly, min_allocator<MoveOnly>> c;
+ std::vector<MoveOnly, min_allocator<MoveOnly> > c;
c.push_back(MoveOnly(0));
assert(c.size() == 1);
assert(is_contiguous_container_asan_correct(c));
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
// <vector>
x.emplace_back();
}
{
- std::vector<BadUserNoCookie<2>> x;
+ std::vector<BadUserNoCookie<2> > x;
BadUserNoCookie<2> c;
x.push_back(c);
}
static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
static_assert((std::is_same<typename R::pointer, It>::value), "");
static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
-#if TEST_STD_VER >= 11
static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
-#else
- static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
-#endif
#if TEST_STD_VER > 17
if constexpr (std::is_same_v<typename T::iterator_category, std::contiguous_iterator_tag>) {
static_assert((std::is_same<typename R::iterator_category, std::random_access_iterator_tag>::value), "");
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03 && !stdlib=libc++
+
// <utility>
// template <class T>
A a;
const A ca;
-#if TEST_STD_VER >= 11
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
-#else // C++ < 11
- // In C++03 we don't have noexcept so we can never move :-(
- static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int&>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A&>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
-#endif
#if TEST_STD_VER > 11
constexpr int i1 = 23;
#include "test_macros.h"
-#if TEST_STD_VER >= 11
-
#include <cstddef>
#include <functional>
{
int data_;
public:
- constexpr MoveOnly(int data = 1) : data_(data) {}
+ TEST_CONSTEXPR MoveOnly(int data = 1) : data_(data) {}
+
+ MoveOnly(const MoveOnly&) = delete;
+ MoveOnly& operator=(const MoveOnly&) = delete;
+
TEST_CONSTEXPR_CXX14 MoveOnly(MoveOnly&& x)
: data_(x.data_) {x.data_ = 0;}
TEST_CONSTEXPR_CXX14 MoveOnly& operator=(MoveOnly&& x)
{data_ = x.data_; x.data_ = 0; return *this;}
- constexpr int get() const {return data_;}
+ TEST_CONSTEXPR int get() const {return data_;}
- friend constexpr bool operator==(const MoveOnly& x, const MoveOnly& y)
+ friend TEST_CONSTEXPR bool operator==(const MoveOnly& x, const MoveOnly& y)
{ return x.data_ == y.data_; }
- friend constexpr bool operator!=(const MoveOnly& x, const MoveOnly& y)
+ friend TEST_CONSTEXPR bool operator!=(const MoveOnly& x, const MoveOnly& y)
{ return x.data_ != y.data_; }
- friend constexpr bool operator< (const MoveOnly& x, const MoveOnly& y)
+ friend TEST_CONSTEXPR bool operator< (const MoveOnly& x, const MoveOnly& y)
{ return x.data_ < y.data_; }
- friend constexpr bool operator<=(const MoveOnly& x, const MoveOnly& y)
+ friend TEST_CONSTEXPR bool operator<=(const MoveOnly& x, const MoveOnly& y)
{ return x.data_ <= y.data_; }
- friend constexpr bool operator> (const MoveOnly& x, const MoveOnly& y)
+ friend TEST_CONSTEXPR bool operator> (const MoveOnly& x, const MoveOnly& y)
{ return x.data_ > y.data_; }
- friend constexpr bool operator>=(const MoveOnly& x, const MoveOnly& y)
+ friend TEST_CONSTEXPR bool operator>=(const MoveOnly& x, const MoveOnly& y)
{ return x.data_ >= y.data_; }
TEST_CONSTEXPR_CXX14 MoveOnly operator+(const MoveOnly& x) const
- { return MoveOnly{data_ + x.data_}; }
+ { return MoveOnly(data_ + x.data_); }
TEST_CONSTEXPR_CXX14 MoveOnly operator*(const MoveOnly& x) const
- { return MoveOnly{data_ * x.data_}; }
+ { return MoveOnly(data_ * x.data_); }
template<class T, class U>
friend void operator,(T t, U u) = delete;
{
typedef MoveOnly argument_type;
typedef size_t result_type;
- constexpr size_t operator()(const MoveOnly& x) const {return x.get();}
+ TEST_CONSTEXPR size_t operator()(const MoveOnly& x) const {return x.get();}
};
-#endif // TEST_STD_VER >= 11
-
#endif // MOVEONLY_H
}
}
-#if TEST_STD_VER >= 11
TEST_CONSTEXPR_CXX14 test_allocator(test_allocator&& a) TEST_NOEXCEPT : data_(a.data_), id_(a.id_), stats_(a.stats_) {
if (stats_ != nullptr) {
++stats_->count;
a.data_ = test_alloc_base::moved_value;
a.id_ = test_alloc_base::moved_value;
}
-#endif
template <class U>
TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator<U>& a) TEST_NOEXCEPT
TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT { return UINT_MAX / sizeof(T); }
-#if TEST_STD_VER < 11
- void construct(pointer p, const T& val) { ::new (static_cast<void*>(p)) T(val); }
-#else
template <class U>
TEST_CONSTEXPR_CXX14 void construct(pointer p, U&& val) {
::new (static_cast<void*>(p)) T(std::forward<U>(val));
}
-#endif
+
TEST_CONSTEXPR_CXX14 void destroy(pointer p) { p->~T(); }
TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) { return x.data_ == y.data_; }
TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) { return !(x == y); }
#endif
};
-#if TEST_STD_VER >= 11
-
struct Ctor_Tag {};
template <typename T>
// All constructors must be passed the Tag type.
// DefaultInsertable into vector<X, TaggingAllocator<X>>,
- constexpr Tag_X(Ctor_Tag) {}
+ TEST_CONSTEXPR Tag_X(Ctor_Tag) {}
// CopyInsertable into vector<X, TaggingAllocator<X>>,
- constexpr Tag_X(Ctor_Tag, const Tag_X&) {}
+ TEST_CONSTEXPR Tag_X(Ctor_Tag, const Tag_X&) {}
// MoveInsertable into vector<X, TaggingAllocator<X>>, and
- constexpr Tag_X(Ctor_Tag, Tag_X&&) {}
+ TEST_CONSTEXPR Tag_X(Ctor_Tag, Tag_X&&) {}
// EmplaceConstructible into vector<X, TaggingAllocator<X>> from args.
template <typename... Args>
- constexpr Tag_X(Ctor_Tag, Args&&...) {}
+ TEST_CONSTEXPR Tag_X(Ctor_Tag, Args&&...) {}
// not DefaultConstructible, CopyConstructible or MoveConstructible.
Tag_X() = delete;
TaggingAllocator() = default;
template <typename U>
- constexpr TaggingAllocator(const TaggingAllocator<U>&){};
+ TEST_CONSTEXPR TaggingAllocator(const TaggingAllocator<U>&) {}
template <typename... Args>
void construct(Tag_X* p, Args&&... args) {
- ::new ((void*)p) Tag_X(Ctor_Tag{}, std::forward<Args>(args)...);
+ ::new ((void*)p) Tag_X(Ctor_Tag(), std::forward<Args>(args)...);
}
template <typename U>
p->~U();
}
- TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return std::allocator<T>{}.allocate(n); }
- TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>{}.deallocate(p, n); }
+ TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
+ TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
};
-#endif
template <std::size_t MaxAllocs>
struct limited_alloc_handle {