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

llvm-svn: 300602
This commit is contained in:
Eric Fiselier 2017-04-18 21:16:26 +00:00
parent 63f6c02638
commit 7196ee3175
11 changed files with 38 additions and 47 deletions

View File

@ -126,29 +126,28 @@ public:
_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 @@ public:
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 @@ public:
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 @@ public:
_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 @@ public:
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();}

View File

@ -15,6 +15,7 @@
#include <stack>
#include <cassert>
#include "test_macros.h"
#include "test_allocator.h"
struct test
@ -24,10 +25,10 @@ struct test
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();}
};

View File

@ -16,6 +16,7 @@
#include <cassert>
#include <cstddef>
#include "test_macros.h"
#include "test_allocator.h"
template <class C>
@ -37,10 +38,10 @@ struct test
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();}
};

View File

@ -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 @@ struct test
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
}

View File

@ -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 @@ struct test
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
}

View File

@ -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 @@ make(int n)
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
}

View File

@ -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 @@ make(int n)
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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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 @@ make(int n)
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
}

View File

@ -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 @@ int main()
q.push(MoveOnly(3));
assert(q.size() == 3);
assert(q.top() == MoveOnly(3));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}