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

@@ -15,6 +15,7 @@
#include <queue>
#include <cassert>
#include "test_macros.h"
#include "test_allocator.h"
template <class T>
@@ -30,11 +31,11 @@ struct test
: base(comp, c, a) {}
test(const value_compare& comp, const container_type& c,
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,
const test_allocator<int>& a) : base(comp, 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();}
using base::c;

View File

@@ -15,6 +15,7 @@
#include <queue>
#include <cassert>
#include "test_macros.h"
#include "test_allocator.h"
template <class T>
@@ -30,11 +31,11 @@ struct test
: base(comp, a) {}
test(const value_compare& comp, const container_type& c,
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,
const test_allocator<int>& a) : base(comp, 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();}
using base::c;

View File

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

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue>
// priority_queue& operator=(priority_queue&& 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::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
std::priority_queue<MoveOnly> q;
q = std::move(qo);
assert(q.size() == 5);
assert(q.top() == MoveOnly(4));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

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

View File

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

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue>
// priority_queue(priority_queue&& 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::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
std::priority_queue<MoveOnly> q = std::move(qo);
assert(q.size() == 5);
assert(q.top() == MoveOnly(4));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <queue>
// priority_queue()
@@ -25,10 +27,8 @@
int main()
{
#if defined(_LIBCPP_VERSION)
{
typedef std::priority_queue<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
// <queue>
// priority_queue();
@@ -20,7 +22,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<Emplaceable> q;
q.emplace(1, 2.5);
assert(q.top() == Emplaceable(1, 2.5));
@@ -28,5 +29,4 @@ int main()
assert(q.top() == Emplaceable(3, 4.5));
q.emplace(2, 3.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>
// priority_queue();
@@ -20,7 +22,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::priority_queue<MoveOnly> q;
q.push(1);
assert(q.top() == 1);
@@ -28,5 +29,4 @@ int main()
assert(q.top() == 3);
q.push(2);
assert(q.top() == 3);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -15,6 +15,7 @@
#include <queue>
#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
// <queue>
// 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
// <queue>
// 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
// <queue>
// queue(queue&& 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::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::queue<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
// <queue>
// explicit queue(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::queue<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
// <queue>
// queue()
@@ -24,10 +26,8 @@
int main()
{
#if defined(_LIBCPP_VERSION)
{
typedef std::queue<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
// <queue>
// queue(queue&&)
@@ -24,10 +26,8 @@
int main()
{
#if defined(_LIBCPP_VERSION)
{
typedef std::queue<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
// <queue>
// queue& operator=(queue&& 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::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
std::queue<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
// <queue>
// void push(value_type&& v);
@@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
std::queue<MoveOnly> q;
q.push(MoveOnly(1));
assert(q.size() == 1);
@@ -32,5 +33,4 @@ int main()
assert(q.size() == 3);
assert(q.front() == MoveOnly(1));
assert(q.back() == MoveOnly(3));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}