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
diff --git a/include/stack b/include/stack
index c797ea5..b2d4e23 100644
--- a/include/stack
+++ b/include/stack
@@ -126,29 +126,28 @@
_LIBCPP_INLINE_VISIBILITY
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
stack(stack&& __q)
_NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
: 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
stack& operator=(stack&& __q)
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
{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
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>
_LIBCPP_INLINE_VISIBILITY
explicit stack(const _Alloc& __a,
@@ -167,7 +166,7 @@
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__s.c, __a) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
stack(container_type&& __c, const _Alloc& __a,
@@ -180,7 +179,7 @@
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(_VSTD::move(__s.c), __a) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
@@ -193,10 +192,10 @@
_LIBCPP_INLINE_VISIBILITY
void push(const value_type& __v) {c.push_back(__v);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14
@@ -206,8 +205,8 @@
void emplace(_Args&&... __args)
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);}
#endif
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
+
_LIBCPP_INLINE_VISIBILITY
void pop() {c.pop_back();}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
index 94899d4..bac8378 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
@@ -15,6 +15,7 @@
#include <stack>
#include <cassert>
+#include "test_macros.h"
#include "test_allocator.h"
struct test
@@ -24,10 +25,10 @@
explicit test(const test_allocator<int>& a) : base(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(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();}
};
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
index b3cf392..237870b 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
@@ -16,6 +16,7 @@
#include <cassert>
#include <cstddef>
+#include "test_macros.h"
#include "test_allocator.h"
template <class C>
@@ -37,10 +38,10 @@
explicit test(const test_allocator<int>& a) : base(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(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();}
};
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
index 374aa99..b0da1ef 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// template <class Alloc>
@@ -18,7 +20,6 @@
#include "test_allocator.h"
#include "MoveOnly.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
@@ -47,13 +48,10 @@
allocator_type get_allocator() {return this->c.get_allocator();}
};
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
assert(q.get_allocator() == test_allocator<MoveOnly>(4));
assert(q.size() == 5);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
index 5fa5bd2..e75a8a2 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// template <class Alloc>
@@ -18,7 +20,6 @@
#include "test_allocator.h"
#include "MoveOnly.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
@@ -47,14 +48,11 @@
allocator_type get_allocator() {return this->c.get_allocator();}
};
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
assert(q2.size() == 5);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
index 44fab41..d837e3d 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// stack(stack&& q);
@@ -16,7 +18,6 @@
#include "MoveOnly.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
@@ -28,14 +29,11 @@
return c;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::stack<MoveOnly> q2 = std::move(q);
assert(q2.size() == 5);
assert(q.empty());
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
index ab08da9..01d4674 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// explicit stack(container_type&& c);
@@ -16,7 +18,6 @@
#include "MoveOnly.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
@@ -28,12 +29,9 @@
return c;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
assert(q.size() == 5);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
index 2e217c5..ad5b702 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// stack()
@@ -24,10 +26,8 @@
int main()
{
-#if defined(_LIBCPP_VERSION)
{
typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
-#endif // _LIBCPP_VERSION
}
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
index af6793f..14cb6be 100644
--- a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// stack(stack&&)
@@ -24,10 +26,8 @@
int main()
{
-#if defined(_LIBCPP_VERSION)
{
typedef std::stack<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
-#endif // _LIBCPP_VERSION
}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
index 75cbec1..cbb6346 100644
--- a/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// stack& operator=(stack&& q);
@@ -16,7 +18,6 @@
#include "MoveOnly.h"
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
@@ -28,15 +29,12 @@
return c;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::stack<MoveOnly> q2;
q2 = std::move(q);
assert(q2.size() == 5);
assert(q.empty());
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
index 67d0ea3..9165f6e 100644
--- a/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
+++ b/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <stack>
// void push(value_type&& v);
@@ -18,7 +20,6 @@
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::stack<MoveOnly> q;
q.push(MoveOnly(1));
assert(q.size() == 1);
@@ -29,5 +30,4 @@
q.push(MoveOnly(3));
assert(q.size() == 3);
assert(q.top() == MoveOnly(3));
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}