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:
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// template <class Alloc>
|
||||
// explicit priority_queue(const Alloc& a);
|
||||
|
||||
#include <queue>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../../test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct test
|
||||
: public std::priority_queue<T, std::vector<T, test_allocator<T> > >
|
||||
{
|
||||
typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
|
||||
typedef typename base::container_type container_type;
|
||||
typedef typename base::value_compare value_compare;
|
||||
|
||||
explicit test(const test_allocator<int>& a) : base(a) {}
|
||||
test(const value_compare& comp, const test_allocator<int>& a)
|
||||
: 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
|
||||
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
|
||||
test_allocator<int> get_allocator() {return c.get_allocator();}
|
||||
|
||||
using base::c;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int> q((test_allocator<int>(3)));
|
||||
assert(q.c.get_allocator() == test_allocator<int>(3));
|
||||
assert(q.c.size() == 0);
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// template <class Alloc>
|
||||
// priority_queue(const Compare& comp, const Alloc& a);
|
||||
|
||||
#include <queue>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../../test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct test
|
||||
: public std::priority_queue<T, std::vector<T, test_allocator<T> > >
|
||||
{
|
||||
typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
|
||||
typedef typename base::container_type container_type;
|
||||
typedef typename base::value_compare value_compare;
|
||||
|
||||
explicit test(const test_allocator<int>& a) : base(a) {}
|
||||
test(const value_compare& comp, const test_allocator<int>& a)
|
||||
: 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
|
||||
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
|
||||
test_allocator<int> get_allocator() {return c.get_allocator();}
|
||||
|
||||
using base::c;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int> q(std::less<int>(), test_allocator<int>(3));
|
||||
assert(q.c.get_allocator() == test_allocator<int>(3));
|
||||
assert(q.c.size() == 0);
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// template <class Alloc>
|
||||
// priority_queue(const Compare& comp, const container_type& c,
|
||||
// const Alloc& a);
|
||||
|
||||
#include <queue>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../../test_allocator.h"
|
||||
|
||||
template <class C>
|
||||
C
|
||||
make(int n)
|
||||
{
|
||||
C c;
|
||||
for (int i = 0; i < n; ++i)
|
||||
c.push_back(i);
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct test
|
||||
: public std::priority_queue<T, std::vector<T, test_allocator<T> > >
|
||||
{
|
||||
typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
|
||||
typedef typename base::container_type container_type;
|
||||
typedef typename base::value_compare value_compare;
|
||||
|
||||
explicit test(const test_allocator<int>& a) : base(a) {}
|
||||
test(const value_compare& comp, const test_allocator<int>& a)
|
||||
: 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
|
||||
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
|
||||
test_allocator<int> get_allocator() {return c.get_allocator();}
|
||||
|
||||
using base::c;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::vector<int, test_allocator<int> > C;
|
||||
C v = make<C>(5);
|
||||
test<int> q(std::less<int>(), v, test_allocator<int>(3));
|
||||
assert(q.c.get_allocator() == test_allocator<int>(3));
|
||||
assert(q.size() == 5);
|
||||
assert(q.top() == 4);
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// template <class Alloc>
|
||||
// priority_queue(const Compare& comp, container_type&& c,
|
||||
// const Alloc& a);
|
||||
|
||||
#include <queue>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../../test_allocator.h"
|
||||
|
||||
template <class C>
|
||||
C
|
||||
make(int n)
|
||||
{
|
||||
C c;
|
||||
for (int i = 0; i < n; ++i)
|
||||
c.push_back(i);
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct test
|
||||
: public std::priority_queue<T, std::vector<T, test_allocator<T> > >
|
||||
{
|
||||
typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
|
||||
typedef typename base::container_type container_type;
|
||||
typedef typename base::value_compare value_compare;
|
||||
|
||||
explicit test(const test_allocator<int>& a) : base(a) {}
|
||||
test(const value_compare& comp, const test_allocator<int>& a)
|
||||
: 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
|
||||
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
|
||||
test_allocator<int> get_allocator() {return c.get_allocator();}
|
||||
|
||||
using base::c;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::vector<int, test_allocator<int> > C;
|
||||
test<int> q(std::less<int>(), make<C>(5), test_allocator<int>(3));
|
||||
assert(q.c.get_allocator() == test_allocator<int>(3));
|
||||
assert(q.size() == 5);
|
||||
assert(q.top() == 4);
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// template <class Alloc>
|
||||
// priority_queue(const priority_queue& q, const Alloc& a);
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
#include "../../../../test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct test
|
||||
: public std::priority_queue<T, std::vector<T, test_allocator<T> > >
|
||||
{
|
||||
typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
|
||||
typedef typename base::container_type container_type;
|
||||
typedef typename base::value_compare value_compare;
|
||||
|
||||
explicit test(const test_allocator<int>& a) : base(a) {}
|
||||
test(const value_compare& comp, const test_allocator<int>& a)
|
||||
: base(comp, c, a) {}
|
||||
test(const value_compare& comp, const container_type& c,
|
||||
const test_allocator<int>& a) : base(comp, c, a) {}
|
||||
test(const test& q, const test_allocator<int>& a) : base(q, a) {}
|
||||
test_allocator<int> get_allocator() {return c.get_allocator();}
|
||||
|
||||
using base::c;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int> qo(std::less<int>(),
|
||||
make<std::vector<int, test_allocator<int> > >(5),
|
||||
test_allocator<int>(2));
|
||||
test<int> q(qo, test_allocator<int>(6));
|
||||
assert(q.size() == 5);
|
||||
assert(q.c.get_allocator() == test_allocator<int>(6));
|
||||
assert(q.top() == int(4));
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// template <class Alloc>
|
||||
// priority_queue(priority_queue&& q, const Alloc& a);
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
#include "../../../../test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct test
|
||||
: public std::priority_queue<T, std::vector<T, test_allocator<T> > >
|
||||
{
|
||||
typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
|
||||
typedef typename base::container_type container_type;
|
||||
typedef typename base::value_compare value_compare;
|
||||
|
||||
explicit test(const test_allocator<int>& a) : base(a) {}
|
||||
test(const value_compare& comp, const test_allocator<int>& a)
|
||||
: base(comp, c, a) {}
|
||||
test(const value_compare& comp, const container_type& c,
|
||||
const test_allocator<int>& a) : base(comp, c, a) {}
|
||||
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) {}
|
||||
test_allocator<int> get_allocator() {return c.get_allocator();}
|
||||
|
||||
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));
|
||||
test<MoveOnly> q(std::move(qo), test_allocator<MoveOnly>(6));
|
||||
assert(q.size() == 5);
|
||||
assert(q.c.get_allocator() == test_allocator<MoveOnly>(6));
|
||||
assert(q.top() == MoveOnly(4));
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
Reference in New Issue
Block a user