Cleanup _LIBCPP_HAS_NO_<c++11-feature> macro uses in std::stack.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300602 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-04-18 21:16:26 +00:00
parent ce924dce57
commit 7162dceba5
11 changed files with 38 additions and 47 deletions

View File

@@ -126,29 +126,28 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
stack(const stack& __q) : c(__q.c) {} stack(const stack& __q) : c(__q.c) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY
stack& operator=(const stack& __q) {c = __q.c; return *this;}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
stack(stack&& __q) stack(stack&& __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
stack& operator=(const stack& __q) {c = __q.c; return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
stack& operator=(stack&& __q) stack& operator=(stack&& __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
_LIBCPP_INLINE_VISIBILITY
explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit stack(const container_type& __c) : c(__c) {} explicit stack(const container_type& __c) : c(__c) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Alloc> template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit stack(const _Alloc& __a, explicit stack(const _Alloc& __a,
@@ -167,7 +166,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(__s.c, __a) {} : c(__s.c, __a) {}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_CXX03_LANG
template <class _Alloc> template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
stack(container_type&& __c, const _Alloc& __a, stack(container_type&& __c, const _Alloc& __a,
@@ -180,7 +179,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(_VSTD::move(__s.c), __a) {} : c(_VSTD::move(__s.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();}
@@ -193,10 +192,10 @@ 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
@@ -206,8 +205,8 @@ 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_back();} void pop() {c.pop_back();}

View File

@@ -15,6 +15,7 @@
#include <stack> #include <stack>
#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
// <stack> // <stack>
// 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
// <stack> // <stack>
// 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
// <stack> // <stack>
// stack(stack&& q); // stack(stack&& 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::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5)); std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::stack<MoveOnly> q2 = std::move(q); std::stack<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
// <stack> // <stack>
// explicit stack(container_type&& c); // explicit stack(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::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5)); std::stack<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
// <stack> // <stack>
// stack() // stack()
@@ -24,10 +26,8 @@
int main() int main()
{ {
#if defined(_LIBCPP_VERSION)
{ {
typedef std::stack<MoveOnly> C; typedef std::stack<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
// <stack> // <stack>
// stack(stack&&) // stack(stack&&)
@@ -24,10 +26,8 @@
int main() int main()
{ {
#if defined(_LIBCPP_VERSION)
{ {
typedef std::stack<MoveOnly> C; typedef std::stack<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
// <stack> // <stack>
// stack& operator=(stack&& q); // stack& operator=(stack&& 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::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5)); std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::stack<MoveOnly> q2; std::stack<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
// <stack> // <stack>
// 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::stack<MoveOnly> q; std::stack<MoveOnly> q;
q.push(MoveOnly(1)); q.push(MoveOnly(1));
assert(q.size() == 1); assert(q.size() == 1);
@@ -29,5 +30,4 @@ int main()
q.push(MoveOnly(3)); q.push(MoveOnly(3));
assert(q.size() == 3); assert(q.size() == 3);
assert(q.top() == MoveOnly(3)); assert(q.top() == MoveOnly(3));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} }