2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <deque>
|
|
|
|
|
|
|
|
// reference operator[](size_type __i);
|
|
|
|
// const_reference operator[](size_type __i) const;
|
2010-08-22 02:15:28 +02:00
|
|
|
//
|
2010-05-11 21:42:16 +02:00
|
|
|
// reference at(size_type __i);
|
|
|
|
// const_reference at(size_type __i) const;
|
2010-08-22 02:15:28 +02:00
|
|
|
//
|
2010-05-11 21:42:16 +02:00
|
|
|
// reference front();
|
|
|
|
// const_reference front() const;
|
2010-08-22 02:15:28 +02:00
|
|
|
//
|
2010-05-11 21:42:16 +02:00
|
|
|
// reference back();
|
|
|
|
// const_reference back() const;
|
|
|
|
|
|
|
|
#include <deque>
|
|
|
|
#include <cassert>
|
|
|
|
|
2013-06-23 23:17:24 +02:00
|
|
|
#include "../../../min_allocator.h"
|
|
|
|
|
|
|
|
template <class C>
|
|
|
|
C
|
2010-05-11 21:42:16 +02:00
|
|
|
make(int size, int start = 0 )
|
|
|
|
{
|
|
|
|
const int b = 4096 / sizeof(int);
|
|
|
|
int init = 0;
|
|
|
|
if (start > 0)
|
|
|
|
{
|
|
|
|
init = (start+1) / b + ((start+1) % b != 0);
|
|
|
|
init *= b;
|
|
|
|
--init;
|
|
|
|
}
|
2013-06-23 23:17:24 +02:00
|
|
|
C c(init, 0);
|
2010-05-11 21:42:16 +02:00
|
|
|
for (int i = 0; i < init-start; ++i)
|
|
|
|
c.pop_back();
|
|
|
|
for (int i = 0; i < size; ++i)
|
|
|
|
c.push_back(i);
|
|
|
|
for (int i = 0; i < start; ++i)
|
|
|
|
c.pop_front();
|
|
|
|
return c;
|
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
2013-06-23 23:17:24 +02:00
|
|
|
std::deque<int> c = make<std::deque<int> >(10);
|
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c[i] == i);
|
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c.at(i) == i);
|
|
|
|
assert(c.front() == 0);
|
|
|
|
assert(c.back() == 9);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const std::deque<int> c = make<std::deque<int> >(10);
|
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c[i] == i);
|
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c.at(i) == i);
|
|
|
|
assert(c.front() == 0);
|
|
|
|
assert(c.back() == 9);
|
|
|
|
}
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
{
|
|
|
|
std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
|
2010-05-11 21:42:16 +02:00
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c[i] == i);
|
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c.at(i) == i);
|
|
|
|
assert(c.front() == 0);
|
|
|
|
assert(c.back() == 9);
|
|
|
|
}
|
|
|
|
{
|
2013-06-23 23:17:24 +02:00
|
|
|
const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
|
2010-05-11 21:42:16 +02:00
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c[i] == i);
|
|
|
|
for (unsigned i = 0; i < 10; ++i)
|
|
|
|
assert(c.at(i) == i);
|
|
|
|
assert(c.front() == 0);
|
|
|
|
assert(c.back() == 9);
|
|
|
|
}
|
2013-06-23 23:17:24 +02:00
|
|
|
#endif
|
2010-05-11 21:42:16 +02:00
|
|
|
}
|