sync with N3126

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@113101 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-09-05 01:14:30 +00:00
parent a2ccccce89
commit 3991b553df
83 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// priority_queue& operator=(const priority_queue&) = default;
#include <queue>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
int main()
{
std::vector<int> v = make<std::vector<int> >(5);
std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
std::priority_queue<int, std::vector<int>, std::greater<int> > q;
q = qo;
assert(q.size() == 5);
assert(q.top() == 0);
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// priority_queue& operator=(priority_queue&& q);
#include <queue>
#include <cassert>
#include "../../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
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

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// explicit priority_queue(const Compare& comp);
#include <queue>
#include <cassert>
#include "../../../../stack_allocator.h"
int main()
{
std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q((std::less<int>()));
assert(q.size() == 0);
q.push(1);
q.push(2);
assert(q.size() == 2);
assert(q.top() == 2);
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// explicit priority_queue(const Compare& comp, const container_type& c);
#include <queue>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
int main()
{
std::vector<int> v = make<std::vector<int> >(5);
std::priority_queue<int, std::vector<int>, std::greater<int> > q(std::greater<int>(), v);
assert(q.size() == 5);
assert(q.top() == 0);
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// explicit priority_queue(const Compare& comp, container_type&& c);
#include <queue>
#include <cassert>
#include "../../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
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

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// priority_queue(const priority_queue&) = default;
#include <queue>
#include <cassert>
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(i);
return c;
}
int main()
{
std::vector<int> v = make<std::vector<int> >(5);
std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
std::priority_queue<int, std::vector<int>, std::greater<int> > q = qo;
assert(q.size() == 5);
assert(q.top() == 0);
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// priority_queue();
#include <queue>
#include <cassert>
#include "../../../../stack_allocator.h"
int main()
{
std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q;
assert(q.size() == 0);
q.push(1);
q.push(2);
assert(q.size() == 2);
assert(q.top() == 2);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// template <class InputIterator>
// priority_queue(InputIterator first, InputIterator last);
#include <queue>
#include <cassert>
int main()
{
int a[] = {3, 5, 2, 0, 6, 8, 1};
int* an = a + sizeof(a)/sizeof(a[0]);
std::priority_queue<int> q(a, an);
assert(q.size() == an - a);
assert(q.top() == 8);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// template <class InputIterator>
// priority_queue(InputIterator first, InputIterator last, const Compare& comp);
#include <queue>
#include <cassert>
int main()
{
int a[] = {3, 5, 2, 0, 6, 8, 1};
int* an = a + sizeof(a)/sizeof(a[0]);
std::priority_queue<int, std::vector<int>, std::greater<int> >
q(a, an, std::greater<int>());
assert(q.size() == an - a);
assert(q.top() == 0);
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// template <class InputIterator>
// priority_queue(InputIterator first, InputIterator last,
// const Compare& comp, const container_type& c);
#include <queue>
#include <cassert>
int main()
{
int a[] = {3, 5, 2, 0, 6, 8, 1};
const int n = sizeof(a)/sizeof(a[0]);
std::vector<int> v(a, a+n/2);
std::priority_queue<int> q(a+n/2, a+n, std::less<int>(), v);
assert(q.size() == n);
assert(q.top() == 8);
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// template <class InputIterator>
// priority_queue(InputIterator first, InputIterator last,
// const Compare& comp, container_type&& c);
#include <queue>
#include <cassert>
#include "../../../../MoveOnly.h"
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,
std::less<MoveOnly>(),
std::vector<MoveOnly>(a, a+n/2));
assert(q.size() == n);
assert(q.top() == MoveOnly(8));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <queue>
// priority_queue(priority_queue&& q);
#include <queue>
#include <cassert>
#include "../../../../MoveOnly.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class C>
C
make(int n)
{
C c;
for (int i = 0; i < n; ++i)
c.push_back(MoveOnly(i));
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
}