Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::queue and std::priority_queue.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300604 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-04-18 21:23:18 +00:00
parent 7162dceba5
commit a8d1b917ee
21 changed files with 79 additions and 102 deletions

View File

@@ -213,29 +213,27 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
queue(const queue& __q) : c(__q.c) {} queue(const queue& __q) : c(__q.c) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY
queue& operator=(const queue& __q) {c = __q.c; return *this;}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
queue(queue&& __q) queue(queue&& __q)
_NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
: c(_VSTD::move(__q.c)) {} : c(_VSTD::move(__q.c)) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
queue& operator=(const queue& __q) {c = __q.c; return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
queue& operator=(queue&& __q) queue& operator=(queue&& __q)
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
{c = _VSTD::move(__q.c); return *this;} {c = _VSTD::move(__q.c); return *this;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit queue(const container_type& __c) : c(__c) {} explicit queue(const container_type& __c) : c(__c) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
template <class _Alloc> template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit queue(const _Alloc& __a, explicit queue(const _Alloc& __a,
@@ -254,7 +252,7 @@ public:
typename enable_if<uses_allocator<container_type, typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0) _Alloc>::value>::type* = 0)
: c(__c, __a) {} : c(__c, __a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Alloc> template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
queue(container_type&& __c, const _Alloc& __a, queue(container_type&& __c, const _Alloc& __a,
@@ -268,7 +266,7 @@ public:
_Alloc>::value>::type* = 0) _Alloc>::value>::type* = 0)
: c(_VSTD::move(__q.c), __a) {} : c(_VSTD::move(__q.c), __a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();} bool empty() const {return c.empty();}
@@ -286,10 +284,9 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void push(const value_type& __v) {c.push_back(__v);} void push(const value_type& __v) {c.push_back(__v);}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args> template <class... _Args>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14 #if _LIBCPP_STD_VER > 14
@@ -299,8 +296,7 @@ public:
void emplace(_Args&&... __args) void emplace(_Args&&... __args)
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);} { c.emplace_back(_VSTD::forward<_Args>(__args)...);}
#endif #endif
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void pop() {c.pop_front();} void pop() {c.pop_front();}
@@ -418,32 +414,30 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY
priority_queue& operator=(const priority_queue& __q)
{c = __q.c; comp = __q.comp; return *this;}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue(priority_queue&& __q) priority_queue(priority_queue&& __q)
_NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
is_nothrow_move_constructible<value_compare>::value) is_nothrow_move_constructible<value_compare>::value)
: c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
priority_queue& operator=(const priority_queue& __q)
{c = __q.c; comp = __q.comp; return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue& operator=(priority_queue&& __q) priority_queue& operator=(priority_queue&& __q)
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
is_nothrow_move_assignable<value_compare>::value) is_nothrow_move_assignable<value_compare>::value)
{c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit priority_queue(const value_compare& __comp) explicit priority_queue(const value_compare& __comp)
: c(), comp(__comp) {} : c(), comp(__comp) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue(const value_compare& __comp, const container_type& __c); priority_queue(const value_compare& __comp, const container_type& __c);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit priority_queue(const value_compare& __comp, container_type&& __c); explicit priority_queue(const value_compare& __comp, container_type&& __c);
#endif #endif
@@ -455,12 +449,12 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue(_InputIter __f, _InputIter __l, priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp, const container_type& __c); const value_compare& __comp, const container_type& __c);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _InputIter> template <class _InputIter>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue(_InputIter __f, _InputIter __l, priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp, container_type&& __c); const value_compare& __comp, container_type&& __c);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
template <class _Alloc> template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit priority_queue(const _Alloc& __a, explicit priority_queue(const _Alloc& __a,
@@ -482,7 +476,7 @@ public:
priority_queue(const priority_queue& __q, const _Alloc& __a, priority_queue(const priority_queue& __q, const _Alloc& __a,
typename enable_if<uses_allocator<container_type, typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0); _Alloc>::value>::type* = 0);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Alloc> template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
priority_queue(const value_compare& __comp, container_type&& __c, priority_queue(const value_compare& __comp, container_type&& __c,
@@ -494,7 +488,7 @@ public:
priority_queue(priority_queue&& __q, const _Alloc& __a, priority_queue(priority_queue&& __q, const _Alloc& __a,
typename enable_if<uses_allocator<container_type, typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0); _Alloc>::value>::type* = 0);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();} bool empty() const {return c.empty();}
@@ -505,13 +499,13 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void push(const value_type& __v); void push(const value_type& __v);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void push(value_type&& __v); void push(value_type&& __v);
#ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args>
template <class... _Args> _LIBCPP_INLINE_VISIBILITY void emplace(_Args&&... __args); _LIBCPP_INLINE_VISIBILITY
#endif void emplace(_Args&&... __args);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void pop(); void pop();
@@ -531,7 +525,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp
_VSTD::make_heap(c.begin(), c.end(), comp); _VSTD::make_heap(c.begin(), c.end(), comp);
} }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
inline inline
@@ -543,7 +537,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
_VSTD::make_heap(c.begin(), c.end(), comp); _VSTD::make_heap(c.begin(), c.end(), comp);
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
template <class _InputIter> template <class _InputIter>
@@ -569,7 +563,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
_VSTD::make_heap(c.begin(), c.end(), comp); _VSTD::make_heap(c.begin(), c.end(), comp);
} }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
template <class _InputIter> template <class _InputIter>
@@ -584,7 +578,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
_VSTD::make_heap(c.begin(), c.end(), comp); _VSTD::make_heap(c.begin(), c.end(), comp);
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
template <class _Alloc> template <class _Alloc>
@@ -635,7 +629,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue&
_VSTD::make_heap(c.begin(), c.end(), comp); _VSTD::make_heap(c.begin(), c.end(), comp);
} }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
template <class _Alloc> template <class _Alloc>
@@ -664,7 +658,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
_VSTD::make_heap(c.begin(), c.end(), comp); _VSTD::make_heap(c.begin(), c.end(), comp);
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
inline inline
@@ -675,7 +669,7 @@ priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
_VSTD::push_heap(c.begin(), c.end(), comp); _VSTD::push_heap(c.begin(), c.end(), comp);
} }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
inline inline
@@ -686,8 +680,6 @@ priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
_VSTD::push_heap(c.begin(), c.end(), comp); _VSTD::push_heap(c.begin(), c.end(), comp);
} }
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
template <class... _Args> template <class... _Args>
inline inline
@@ -698,8 +690,7 @@ priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
_VSTD::push_heap(c.begin(), c.end(), comp); _VSTD::push_heap(c.begin(), c.end(), comp);
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp, class _Container, class _Compare> template <class _Tp, class _Container, class _Compare>
inline inline

View File

@@ -15,6 +15,7 @@
#include <queue> #include <queue>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
template <class T> template <class T>
@@ -30,11 +31,11 @@ struct test
: base(comp, c, a) {} : base(comp, c, a) {}
test(const value_compare& comp, const container_type& c, test(const value_compare& comp, const container_type& c,
const test_allocator<int>& a) : base(comp, c, a) {} const test_allocator<int>& a) : base(comp, c, a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #if TEST_STD_VER >= 11
test(const value_compare& comp, container_type&& c, test(const value_compare& comp, container_type&& c,
const test_allocator<int>& a) : base(comp, std::move(c), a) {} const test_allocator<int>& a) : base(comp, std::move(c), a) {}
test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif
test_allocator<int> get_allocator() {return c.get_allocator();} test_allocator<int> get_allocator() {return c.get_allocator();}
using base::c; using base::c;

View File

@@ -15,6 +15,7 @@
#include <queue> #include <queue>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
template <class T> template <class T>
@@ -30,11 +31,11 @@ struct test
: base(comp, a) {} : base(comp, a) {}
test(const value_compare& comp, const container_type& c, test(const value_compare& comp, const container_type& c,
const test_allocator<int>& a) : base(comp, c, a) {} const test_allocator<int>& a) : base(comp, c, a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #if TEST_STD_VER >= 11
test(const value_compare& comp, container_type&& c, test(const value_compare& comp, container_type&& c,
const test_allocator<int>& a) : base(comp, std::move(c), a) {} const test_allocator<int>& a) : base(comp, std::move(c), a) {}
test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif
test_allocator<int> get_allocator() {return c.get_allocator();} test_allocator<int> get_allocator() {return c.get_allocator();}
using base::c; using base::c;

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// template <class Alloc> // template <class Alloc>
@@ -17,7 +19,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -52,11 +53,9 @@ struct test
using base::c; using base::c;
}; };
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> qo(std::less<MoveOnly>(), test<MoveOnly> qo(std::less<MoveOnly>(),
make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5), make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5),
test_allocator<MoveOnly>(2)); test_allocator<MoveOnly>(2));
@@ -64,5 +63,4 @@ int main()
assert(q.size() == 5); assert(q.size() == 5);
assert(q.c.get_allocator() == test_allocator<MoveOnly>(6)); assert(q.c.get_allocator() == test_allocator<MoveOnly>(6));
assert(q.top() == MoveOnly(4)); assert(q.top() == MoveOnly(4));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// priority_queue& operator=(priority_queue&& q); // priority_queue& operator=(priority_queue&& q);
@@ -16,7 +18,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -28,15 +29,12 @@ make(int n)
return c; return c;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5)); std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
std::priority_queue<MoveOnly> q; std::priority_queue<MoveOnly> q;
q = std::move(qo); q = std::move(qo);
assert(q.size() == 5); assert(q.size() == 5);
assert(q.top() == MoveOnly(4)); assert(q.top() == MoveOnly(4));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// explicit priority_queue(const Compare& comp, container_type&& c); // explicit priority_queue(const Compare& comp, container_type&& c);
@@ -16,7 +18,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -28,13 +29,10 @@ make(int n)
return c; return c;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5)); std::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
assert(q.size() == 5); assert(q.size() == 5);
assert(q.top() == MoveOnly(4)); assert(q.top() == MoveOnly(4));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// template <class InputIterator> // template <class InputIterator>
@@ -20,7 +22,6 @@
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
int a[] = {3, 5, 2, 0, 6, 8, 1}; int a[] = {3, 5, 2, 0, 6, 8, 1};
const int n = sizeof(a)/sizeof(a[0]); const int n = sizeof(a)/sizeof(a[0]);
std::priority_queue<MoveOnly> q(a+n/2, a+n, std::priority_queue<MoveOnly> q(a+n/2, a+n,
@@ -28,5 +29,4 @@ int main()
std::vector<MoveOnly>(a, a+n/2)); std::vector<MoveOnly>(a, a+n/2));
assert(q.size() == n); assert(q.size() == n);
assert(q.top() == MoveOnly(8)); assert(q.top() == MoveOnly(8));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// priority_queue(priority_queue&& q); // priority_queue(priority_queue&& q);
@@ -16,7 +18,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -28,14 +29,11 @@ make(int n)
return c; return c;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5)); std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
std::priority_queue<MoveOnly> q = std::move(qo); std::priority_queue<MoveOnly> q = std::move(qo);
assert(q.size() == 5); assert(q.size() == 5);
assert(q.top() == MoveOnly(4)); assert(q.top() == MoveOnly(4));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// priority_queue() // priority_queue()
@@ -25,10 +27,8 @@
int main() int main()
{ {
#if defined(_LIBCPP_VERSION)
{ {
typedef std::priority_queue<MoveOnly> C; typedef std::priority_queue<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, ""); static_assert(std::is_nothrow_default_constructible<C>::value, "");
} }
#endif // _LIBCPP_VERSION
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// priority_queue(); // priority_queue();
@@ -20,7 +22,6 @@
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<Emplaceable> q; std::priority_queue<Emplaceable> q;
q.emplace(1, 2.5); q.emplace(1, 2.5);
assert(q.top() == Emplaceable(1, 2.5)); assert(q.top() == Emplaceable(1, 2.5));
@@ -28,5 +29,4 @@ int main()
assert(q.top() == Emplaceable(3, 4.5)); assert(q.top() == Emplaceable(3, 4.5));
q.emplace(2, 3.5); q.emplace(2, 3.5);
assert(q.top() == Emplaceable(3, 4.5)); assert(q.top() == Emplaceable(3, 4.5));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// priority_queue(); // priority_queue();
@@ -20,7 +22,6 @@
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<MoveOnly> q; std::priority_queue<MoveOnly> q;
q.push(1); q.push(1);
assert(q.top() == 1); assert(q.top() == 1);
@@ -28,5 +29,4 @@ int main()
assert(q.top() == 3); assert(q.top() == 3);
q.push(2); q.push(2);
assert(q.top() == 3); assert(q.top() == 3);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -15,6 +15,7 @@
#include <queue> #include <queue>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
struct test struct test
@@ -24,10 +25,10 @@ struct test
explicit test(const test_allocator<int>& a) : base(a) {} explicit test(const test_allocator<int>& a) : base(a) {}
test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #if TEST_STD_VER >= 11
test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif
test_allocator<int> get_allocator() {return c.get_allocator();} test_allocator<int> get_allocator() {return c.get_allocator();}
}; };

View File

@@ -16,6 +16,7 @@
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
template <class C> template <class C>
@@ -37,10 +38,10 @@ struct test
explicit test(const test_allocator<int>& a) : base(a) {} explicit test(const test_allocator<int>& a) : base(a) {}
test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #if TEST_STD_VER >= 11
test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif
test_allocator<int> get_allocator() {return c.get_allocator();} test_allocator<int> get_allocator() {return c.get_allocator();}
}; };

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// template <class Alloc> // template <class Alloc>
@@ -18,7 +20,6 @@
#include "test_allocator.h" #include "test_allocator.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -47,13 +48,10 @@ struct test
allocator_type get_allocator() {return this->c.get_allocator();} allocator_type get_allocator() {return this->c.get_allocator();}
}; };
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
assert(q.get_allocator() == test_allocator<MoveOnly>(4)); assert(q.get_allocator() == test_allocator<MoveOnly>(4));
assert(q.size() == 5); assert(q.size() == 5);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// template <class Alloc> // template <class Alloc>
@@ -18,7 +20,6 @@
#include "test_allocator.h" #include "test_allocator.h"
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -47,14 +48,11 @@ struct test
allocator_type get_allocator() {return this->c.get_allocator();} allocator_type get_allocator() {return this->c.get_allocator();}
}; };
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4)); test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5)); test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
assert(q2.get_allocator() == test_allocator<MoveOnly>(5)); assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
assert(q2.size() == 5); assert(q2.size() == 5);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// queue(queue&& q); // queue(queue&& q);
@@ -16,7 +18,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -28,14 +29,11 @@ make(int n)
return c; return c;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5)); std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::queue<MoveOnly> q2 = std::move(q); std::queue<MoveOnly> q2 = std::move(q);
assert(q2.size() == 5); assert(q2.size() == 5);
assert(q.empty()); assert(q.empty());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// explicit queue(container_type&& c); // explicit queue(container_type&& c);
@@ -16,7 +18,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -28,12 +29,9 @@ make(int n)
return c; return c;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5)); std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
assert(q.size() == 5); assert(q.size() == 5);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// queue() // queue()
@@ -24,10 +26,8 @@
int main() int main()
{ {
#if defined(_LIBCPP_VERSION)
{ {
typedef std::queue<MoveOnly> C; typedef std::queue<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, ""); static_assert(std::is_nothrow_default_constructible<C>::value, "");
} }
#endif // _LIBCPP_VERSION
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// queue(queue&&) // queue(queue&&)
@@ -24,10 +26,8 @@
int main() int main()
{ {
#if defined(_LIBCPP_VERSION)
{ {
typedef std::queue<MoveOnly> C; typedef std::queue<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, ""); static_assert(std::is_nothrow_move_constructible<C>::value, "");
} }
#endif // _LIBCPP_VERSION
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// queue& operator=(queue&& q); // queue& operator=(queue&& q);
@@ -16,7 +18,6 @@
#include "MoveOnly.h" #include "MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C> template <class C>
C C
@@ -28,15 +29,12 @@ make(int n)
return c; return c;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5)); std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::queue<MoveOnly> q2; std::queue<MoveOnly> q2;
q2 = std::move(q); q2 = std::move(q);
assert(q2.size() == 5); assert(q2.size() == 5);
assert(q.empty()); assert(q.empty());
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue> // <queue>
// void push(value_type&& v); // void push(value_type&& v);
@@ -18,7 +20,6 @@
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::queue<MoveOnly> q; std::queue<MoveOnly> q;
q.push(MoveOnly(1)); q.push(MoveOnly(1));
assert(q.size() == 1); assert(q.size() == 1);
@@ -32,5 +33,4 @@ int main()
assert(q.size() == 3); assert(q.size() == 3);
assert(q.front() == MoveOnly(1)); assert(q.front() == MoveOnly(1));
assert(q.back() == MoveOnly(3)); assert(q.back() == MoveOnly(3));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }