Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// reference front();
|
||||
// const_reference front() const;
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
assert(c.front() == 0);
|
||||
c.front() = 10;
|
||||
assert(c.front() == 10);
|
||||
assert(*c.begin() == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const C c(std::begin(t), std::end(t));
|
||||
assert(c.front() == 0);
|
||||
assert(*c.begin() == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
assert(c.front() == 0);
|
||||
c.front() = 10;
|
||||
assert(c.front() == 10);
|
||||
assert(*c.begin() == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const C c(std::begin(t), std::end(t));
|
||||
assert(c.front() == 0);
|
||||
assert(*c.begin() == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "../../../NotConstructible.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef test_allocator<NotConstructible> A;
|
||||
typedef A::value_type T;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c = A(12);
|
||||
assert(c.get_allocator() == A(12));
|
||||
assert(c.empty());
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "../../../NotConstructible.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef test_allocator<NotConstructible> A;
|
||||
typedef A::value_type T;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c(A(12));
|
||||
assert(c.get_allocator() == A(12));
|
||||
assert(c.empty());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef min_allocator<NotConstructible> A;
|
||||
typedef A::value_type T;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c(A{});
|
||||
assert(c.get_allocator() == A());
|
||||
assert(c.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,146 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(const forward_list& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(10));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(11));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(11));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(10));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(11));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(11));
|
||||
}
|
||||
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(10));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(11));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(10));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t0), std::end(t0), A(10));
|
||||
C c1(std::begin(t1), std::end(t1), A(11));
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c0(std::begin(t0), std::end(t0), A());
|
||||
C c1(std::begin(t1), std::end(t1), A());
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t0), std::end(t0), A());
|
||||
C c1(std::begin(t1), std::end(t1), A());
|
||||
c1 = c0;
|
||||
assert(c1 == c0);
|
||||
assert(c1.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void assign(initializer_list<value_type> il);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign({10, 11, 12, 13});
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign({10, 11, 12, 13});
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
@@ -0,0 +1,199 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(forward_list&& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
T t1[] = {10, 11, 12, 13};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
assert(c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
T t1[] = {10, 11, 12, 13};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c1.get_allocator() == A(11));
|
||||
assert(!c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {10, 11, 12, 13};
|
||||
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
assert(c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {10, 11, 12, 13};
|
||||
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
assert(c1.get_allocator() == A(11));
|
||||
assert(!c0.empty());
|
||||
}
|
||||
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
T t1[] = {10, 11, 12, 13};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
assert(c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
T t1[] = {10, 11, 12, 13};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
assert(c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {10, 11, 12, 13};
|
||||
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
assert(c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {10, 11, 12, 13};
|
||||
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
assert(c1.get_allocator() == A(10));
|
||||
assert(c0.empty());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
T t1[] = {10, 11, 12, 13};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A());
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A());
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c1.get_allocator() == A());
|
||||
assert(c0.empty());
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t0[] = {10, 11, 12, 13};
|
||||
T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t0)), I(std::end(t0)), A());
|
||||
C c1(I(std::begin(t1)), I(std::end(t1)), A());
|
||||
c1 = std::move(c0);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
assert(c1.get_allocator() == A());
|
||||
assert(c0.empty());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(initializer_list<value_type> il);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c = {10, 11, 12, 13};
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c = {10, 11, 12, 13};
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class InputIterator>
|
||||
// void assign(InputIterator first, InputIterator last);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
typedef input_iterator<const T*> I;
|
||||
c.assign(I(std::begin(t0)), I(std::end(t0)));
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
typedef input_iterator<const T*> I;
|
||||
c.assign(I(std::begin(t0)), I(std::end(t0)));
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
typedef input_iterator<const T*> I;
|
||||
c.assign(I(std::begin(t0)), I(std::end(t0)));
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t0[] = {10, 11, 12, 13};
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
typedef input_iterator<const T*> I;
|
||||
c.assign(I(std::begin(t0)), I(std::end(t0)));
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, (void) ++n)
|
||||
assert(*i == 10+n);
|
||||
assert(n == 4);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void assign(size_type n, const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign(10, 1);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 1);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign(4, 10);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10);
|
||||
assert(n == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {10, 11, 12, 13};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign(10, 1);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 1);
|
||||
assert(n == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t1), std::end(t1));
|
||||
c.assign(4, 10);
|
||||
int n = 0;
|
||||
for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
|
||||
assert(*i == 10);
|
||||
assert(n == 4);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(const forward_list& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t), std::end(t), A(10));
|
||||
C c = c0;
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c == c0);
|
||||
assert(c.get_allocator() == A(10));
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t), std::end(t), A(10));
|
||||
C c = c0;
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c == c0);
|
||||
assert(c.get_allocator() == A(-2));
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t), std::end(t), A());
|
||||
C c = c0;
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c == c0);
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(const forward_list& x, const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t), std::end(t), A(10));
|
||||
C c(c0, A(9));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c == c0);
|
||||
assert(c.get_allocator() == A(9));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t), std::end(t), A(10));
|
||||
C c(c0, A(9));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c == c0);
|
||||
assert(c.get_allocator() == A(9));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c0(std::begin(t), std::end(t), A());
|
||||
C c(c0, A());
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c == c0);
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list();
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
assert(c.empty());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
assert(c.empty());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c = {};
|
||||
assert(c.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list()
|
||||
// noexcept(is_nothrow_default_constructible<allocator_type>::value);
|
||||
|
||||
// This tests a conforming extension
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct some_alloc
|
||||
{
|
||||
typedef T value_type;
|
||||
some_alloc(const some_alloc&);
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::forward_list<MoveOnly> C;
|
||||
static_assert(std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
|
||||
static_assert(std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
|
||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
|
||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// class forward_list
|
||||
|
||||
// forward_list();
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
struct X
|
||||
{
|
||||
std::forward_list<X> q;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// ~forward_list() // implied noexcept;
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
#if __has_feature(cxx_noexcept)
|
||||
|
||||
template <class T>
|
||||
struct some_alloc
|
||||
{
|
||||
typedef T value_type;
|
||||
some_alloc(const some_alloc&);
|
||||
~some_alloc() noexcept(false);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::forward_list<MoveOnly> C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
|
||||
static_assert(!std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(initializer_list<value_type> il);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(initializer_list<value_type> il, const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c.get_allocator() == A(14));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A());
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == 10);
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(forward_list&& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t)), I(std::end(t)), A(10));
|
||||
C c = std::move(c0);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c0.empty());
|
||||
assert(c.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef other_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t)), I(std::end(t)), A(10));
|
||||
C c = std::move(c0);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c0.empty());
|
||||
assert(c.get_allocator() == A(10));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef min_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t)), I(std::end(t)), A());
|
||||
C c = std::move(c0);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c0.empty());
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(forward_list&& x, const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t)), I(std::end(t)), A(10));
|
||||
C c(std::move(c0), A(10));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c0.empty());
|
||||
assert(c.get_allocator() == A(10));
|
||||
}
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef test_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t)), I(std::end(t)), A(10));
|
||||
C c(std::move(c0), A(9));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(!c0.empty());
|
||||
assert(c.get_allocator() == A(9));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef min_allocator<int> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
typedef std::move_iterator<T*> I;
|
||||
C c0(I(std::begin(t)), I(std::end(t)), A());
|
||||
C c(std::move(c0), A());
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c0.empty());
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list& operator=(forward_list&& c)
|
||||
// noexcept(
|
||||
// allocator_type::propagate_on_container_move_assignment::value &&
|
||||
// is_nothrow_move_assignable<allocator_type>::value);
|
||||
|
||||
// This tests a conforming extension
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct some_alloc
|
||||
{
|
||||
typedef T value_type;
|
||||
some_alloc(const some_alloc&);
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::forward_list<MoveOnly> C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(forward_list&&)
|
||||
// noexcept(is_nothrow_move_constructible<allocator_type>::value);
|
||||
|
||||
// This tests a conforming extension
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct some_alloc
|
||||
{
|
||||
typedef T value_type;
|
||||
some_alloc(const some_alloc&);
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::forward_list<MoveOnly> C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
|
||||
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class InputIterator>
|
||||
// forward_list(InputIterator first, InputIterator last);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef input_iterator<const T*> I;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(I(std::begin(t)), I(std::end(t)));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef input_iterator<const T*> I;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(I(std::begin(t)), I(std::end(t)));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class InputIterator>
|
||||
// forward_list(InputIterator first, InputIterator last,
|
||||
// const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
typedef input_iterator<const T*> I;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(I(std::begin(t)), I(std::end(t)), A(13));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c.get_allocator() == A(13));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
typedef input_iterator<const T*> I;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(I(std::begin(t)), I(std::end(t)), A());
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == n);
|
||||
assert(n == std::end(t) - std::begin(t));
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(size_type n);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
unsigned N = 10;
|
||||
C c = N;
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
assert(*i == T());
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
assert(n == N);
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// explicit forward_list(size_type n);
|
||||
// explicit forward_list(size_type n, const Alloc& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "DefaultOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class T, class Allocator>
|
||||
void check_allocator(unsigned n, Allocator const &alloc = Allocator())
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::forward_list<T, Allocator> C;
|
||||
C d(n, alloc);
|
||||
assert(d.get_allocator() == alloc);
|
||||
assert(std::distance(d.begin(), d.end()) == n);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
unsigned N = 10;
|
||||
C c(N);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
assert(*i == T());
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
assert(n == N);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
unsigned N = 10;
|
||||
C c(N);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
assert(*i == T());
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
assert(n == N);
|
||||
check_allocator<T, min_allocator<T>> ( 0 );
|
||||
check_allocator<T, min_allocator<T>> ( 3 );
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(size_type n, const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
T v(6);
|
||||
unsigned N = 10;
|
||||
C c(N, v);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == v);
|
||||
assert(n == N);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
T v(6);
|
||||
unsigned N = 10;
|
||||
C c(N, v);
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == v);
|
||||
assert(n == N);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// forward_list(size_type n, const value_type& v, const allocator_type& a);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef test_allocator<int> A;
|
||||
typedef A::value_type T;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T v(6);
|
||||
unsigned N = 10;
|
||||
C c(N, v, A(12));
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == v);
|
||||
assert(n == N);
|
||||
assert(c.get_allocator() == A(12));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef min_allocator<int> A;
|
||||
typedef A::value_type T;
|
||||
typedef std::forward_list<T, A> C;
|
||||
T v(6);
|
||||
unsigned N = 10;
|
||||
C c(N, v, A());
|
||||
unsigned n = 0;
|
||||
for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
|
||||
assert(*i == v);
|
||||
assert(n == N);
|
||||
assert(c.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator before_begin();
|
||||
// const_iterator before_begin() const;
|
||||
// const_iterator cbefore_begin() const;
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
C::iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 1);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 1);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.cbefore_begin();
|
||||
assert(std::distance(i, c.end()) == 1);
|
||||
assert(c.cbefore_begin() == c.before_begin());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
C::iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 11);
|
||||
assert(std::next(c.before_begin()) == c.begin());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const C c(std::begin(t), std::end(t));
|
||||
C::const_iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 11);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 1);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 1);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.cbefore_begin();
|
||||
assert(std::distance(i, c.end()) == 1);
|
||||
assert(c.cbefore_begin() == c.before_begin());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
C::iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 11);
|
||||
assert(std::next(c.before_begin()) == c.begin());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
const C c(std::begin(t), std::end(t));
|
||||
C::const_iterator i = c.before_begin();
|
||||
assert(std::distance(i, c.end()) == 11);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,145 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator begin();
|
||||
// iterator end();
|
||||
// const_iterator begin() const;
|
||||
// const_iterator end() const;
|
||||
// const_iterator cbegin() const;
|
||||
// const_iterator cend() const;
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
C::iterator i = c.begin();
|
||||
C::iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.begin();
|
||||
C::const_iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
C::const_iterator i = c.cbegin();
|
||||
C::const_iterator j = c.cend();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
assert(i == c.end());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
C::iterator i = c.begin();
|
||||
assert(*i == 0);
|
||||
++i;
|
||||
assert(*i == 1);
|
||||
*i = 10;
|
||||
assert(*i == 10);
|
||||
assert(std::distance(c.begin(), c.end()) == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::iterator i = c.begin();
|
||||
C::iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.begin();
|
||||
C::const_iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::const_iterator i = c.cbegin();
|
||||
C::const_iterator j = c.cend();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
assert(i == c.end());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
C::iterator i = c.begin();
|
||||
assert(*i == 0);
|
||||
++i;
|
||||
assert(*i == 1);
|
||||
*i = 10;
|
||||
assert(*i == 10);
|
||||
assert(std::distance(c.begin(), c.end()) == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
#endif
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{ // N3644 testing
|
||||
std::forward_list<int>::iterator ii1{}, ii2{};
|
||||
std::forward_list<int>::iterator ii4 = ii1;
|
||||
std::forward_list<int>::const_iterator cii{};
|
||||
assert ( ii1 == ii2 );
|
||||
assert ( ii1 == ii4 );
|
||||
|
||||
assert (!(ii1 != ii2 ));
|
||||
|
||||
assert ( (ii1 == cii ));
|
||||
assert ( (cii == ii1 ));
|
||||
assert (!(ii1 != cii ));
|
||||
assert (!(cii != ii1 ));
|
||||
|
||||
// std::forward_list<int> c;
|
||||
// assert ( ii1 != c.cbegin());
|
||||
// assert ( cii != c.begin());
|
||||
// assert ( cii != c.cend());
|
||||
// assert ( ii1 != c.end());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void clear();
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../NotConstructible.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef NotConstructible T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.clear();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
c.clear();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
c.clear();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef NotConstructible T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.clear();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
c.clear();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
c.clear();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace_after(const_iterator p, Args&&... args);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef Emplaceable T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.emplace_after(c.cbefore_begin());
|
||||
assert(i == c.begin());
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
|
||||
i = c.emplace_after(c.cbegin(), 1, 2.5);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(*next(c.begin()) == Emplaceable(1, 2.5));
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
|
||||
i = c.emplace_after(next(c.cbegin()), 2, 3.5);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(*next(c.begin()) == Emplaceable(1, 2.5));
|
||||
assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
|
||||
i = c.emplace_after(c.cbegin(), 3, 4.5);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
|
||||
assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
|
||||
assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef Emplaceable T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.emplace_after(c.cbefore_begin());
|
||||
assert(i == c.begin());
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
|
||||
i = c.emplace_after(c.cbegin(), 1, 2.5);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(*next(c.begin()) == Emplaceable(1, 2.5));
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
|
||||
i = c.emplace_after(next(c.cbegin()), 2, 3.5);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(*next(c.begin()) == Emplaceable(1, 2.5));
|
||||
assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
|
||||
i = c.emplace_after(c.cbegin(), 3, 4.5);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
|
||||
assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
|
||||
assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class... Args> void emplace_front(Args&&... args);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef Emplaceable T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.emplace_front();
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
c.emplace_front(1, 2.5);
|
||||
assert(c.front() == Emplaceable(1, 2.5));
|
||||
assert(*next(c.begin()) == Emplaceable());
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef Emplaceable T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.emplace_front();
|
||||
assert(c.front() == Emplaceable());
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
c.emplace_front(1, 2.5);
|
||||
assert(c.front() == Emplaceable(1, 2.5));
|
||||
assert(*next(c.begin()) == Emplaceable());
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator erase_after(const_iterator first, const_iterator last);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
|
||||
assert(i == next(c.cbefore_begin(), 4));
|
||||
assert(distance(c.begin(), c.end()) == 10);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 3);
|
||||
assert(*next(c.begin(), 4) == 4);
|
||||
assert(*next(c.begin(), 5) == 5);
|
||||
assert(*next(c.begin(), 6) == 6);
|
||||
assert(*next(c.begin(), 7) == 7);
|
||||
assert(*next(c.begin(), 8) == 8);
|
||||
assert(*next(c.begin(), 9) == 9);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 8);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 5);
|
||||
assert(*next(c.begin(), 4) == 6);
|
||||
assert(*next(c.begin(), 5) == 7);
|
||||
assert(*next(c.begin(), 6) == 8);
|
||||
assert(*next(c.begin(), 7) == 9);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 8);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 5);
|
||||
assert(*next(c.begin(), 4) == 6);
|
||||
assert(*next(c.begin(), 5) == 7);
|
||||
assert(*next(c.begin(), 6) == 8);
|
||||
assert(*next(c.begin(), 7) == 9);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 5);
|
||||
assert(*next(c.begin(), 4) == 6);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
|
||||
assert(i == c.begin());
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
assert(*next(c.begin(), 1) == 4);
|
||||
assert(*next(c.begin(), 2) == 5);
|
||||
assert(*next(c.begin(), 3) == 6);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
|
||||
assert(i == c.begin());
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
|
||||
assert(i == next(c.cbefore_begin(), 4));
|
||||
assert(distance(c.begin(), c.end()) == 10);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 3);
|
||||
assert(*next(c.begin(), 4) == 4);
|
||||
assert(*next(c.begin(), 5) == 5);
|
||||
assert(*next(c.begin(), 6) == 6);
|
||||
assert(*next(c.begin(), 7) == 7);
|
||||
assert(*next(c.begin(), 8) == 8);
|
||||
assert(*next(c.begin(), 9) == 9);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 8);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 5);
|
||||
assert(*next(c.begin(), 4) == 6);
|
||||
assert(*next(c.begin(), 5) == 7);
|
||||
assert(*next(c.begin(), 6) == 8);
|
||||
assert(*next(c.begin(), 7) == 9);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 8);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 5);
|
||||
assert(*next(c.begin(), 4) == 6);
|
||||
assert(*next(c.begin(), 5) == 7);
|
||||
assert(*next(c.begin(), 6) == 8);
|
||||
assert(*next(c.begin(), 7) == 9);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 5);
|
||||
assert(*next(c.begin(), 4) == 6);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
|
||||
assert(i == c.begin());
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
assert(*next(c.begin(), 1) == 4);
|
||||
assert(*next(c.begin(), 2) == 5);
|
||||
assert(*next(c.begin(), 3) == 6);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
|
||||
assert(i == c.begin());
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator erase_after(const_iterator p);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 3);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0));
|
||||
assert(i == c.begin());
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
assert(*next(c.begin(), 1) == 2);
|
||||
assert(*next(c.begin(), 2) == 3);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 1));
|
||||
assert(i == next(c.begin()));
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 1));
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0));
|
||||
assert(i == c.begin());
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 3);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0));
|
||||
assert(i == c.begin());
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
assert(*next(c.begin(), 1) == 2);
|
||||
assert(*next(c.begin(), 2) == 3);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 1));
|
||||
assert(i == next(c.begin()));
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 1));
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
assert(*next(c.begin(), 0) == 1);
|
||||
|
||||
i = c.erase_after(next(c.cbefore_begin(), 0));
|
||||
assert(i == c.begin());
|
||||
assert(i == c.end());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), 0);
|
||||
assert(i == c.begin());
|
||||
assert(c.front() == 0);
|
||||
assert(c.front() == 0);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 1);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
|
||||
i = c.insert_after(next(c.cbegin()), 2);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 3);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 1);
|
||||
assert(*next(c.begin(), 3) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), 0);
|
||||
assert(i == c.begin());
|
||||
assert(c.front() == 0);
|
||||
assert(c.front() == 0);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 1);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
|
||||
i = c.insert_after(next(c.cbegin()), 2);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 3);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 1);
|
||||
assert(*next(c.begin(), 3) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, initializer_list<value_type> il);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), {});
|
||||
assert(i == c.before_begin());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
|
||||
assert(i == next(c.before_begin(), 3));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
i = c.insert_after(c.begin(), {3, 4});
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 1);
|
||||
assert(*next(c.begin(), 4) == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), {});
|
||||
assert(i == c.before_begin());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
|
||||
assert(i == next(c.before_begin(), 3));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
i = c.insert_after(c.begin(), {3, 4});
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 1);
|
||||
assert(*next(c.begin(), 4) == 2);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class InputIterator>
|
||||
// iterator insert_after(const_iterator p,
|
||||
// InputIterator first, InputIterator last);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef C::iterator I;
|
||||
typedef input_iterator<const T*> J;
|
||||
C c;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
|
||||
assert(i == c.before_begin());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
|
||||
assert(i == next(c.before_begin(), 3));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
i = c.insert_after(c.begin(), J(t+3), J(t+5));
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 1);
|
||||
assert(*next(c.begin(), 4) == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef C::iterator I;
|
||||
typedef input_iterator<const T*> J;
|
||||
C c;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
|
||||
assert(i == c.before_begin());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
|
||||
assert(i == next(c.before_begin(), 3));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
i = c.insert_after(c.begin(), J(t+3), J(t+5));
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 4);
|
||||
assert(*next(c.begin(), 3) == 1);
|
||||
assert(*next(c.begin(), 4) == 2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, value_type&& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), 0);
|
||||
assert(i == c.begin());
|
||||
assert(c.front() == 0);
|
||||
assert(c.front() == 0);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 1);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
|
||||
i = c.insert_after(next(c.cbegin()), 2);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 3);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 1);
|
||||
assert(*next(c.begin(), 3) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), 0);
|
||||
assert(i == c.begin());
|
||||
assert(c.front() == 0);
|
||||
assert(c.front() == 0);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 1);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
|
||||
i = c.insert_after(next(c.cbegin()), 2);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
|
||||
i = c.insert_after(c.cbegin(), 3);
|
||||
assert(i == next(c.begin()));
|
||||
assert(c.front() == 0);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 1);
|
||||
assert(*next(c.begin(), 3) == 2);
|
||||
assert(distance(c.begin(), c.end()) == 4);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// iterator insert_after(const_iterator p, size_type n, const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), 0, 0);
|
||||
assert(i == c.before_begin());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
i = c.insert_after(c.cbefore_begin(), 3, 3);
|
||||
assert(i == next(c.before_begin(), 3));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 3);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 3);
|
||||
|
||||
i = c.insert_after(c.begin(), 2, 2);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 3);
|
||||
assert(*next(c.begin(), 1) == 2);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 3);
|
||||
assert(*next(c.begin(), 4) == 3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef C::iterator I;
|
||||
C c;
|
||||
I i = c.insert_after(c.cbefore_begin(), 0, 0);
|
||||
assert(i == c.before_begin());
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
|
||||
i = c.insert_after(c.cbefore_begin(), 3, 3);
|
||||
assert(i == next(c.before_begin(), 3));
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 3);
|
||||
assert(*next(c.begin(), 1) == 3);
|
||||
assert(*next(c.begin(), 2) == 3);
|
||||
|
||||
i = c.insert_after(c.begin(), 2, 2);
|
||||
assert(i == next(c.begin(), 2));
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
assert(*next(c.begin(), 0) == 3);
|
||||
assert(*next(c.begin(), 1) == 2);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 3);
|
||||
assert(*next(c.begin(), 4) == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void pop_front();
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
c.push_front(3);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
assert(c.front() == 1);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
c.push_front(3);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
assert(c.front() == 1);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
c.push_front(3);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
assert(c.front() == 1);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
c.push_front(3);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
assert(c.front() == 1);
|
||||
c.pop_front();
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void push_front(const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
assert(c.front() == 1);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
c.push_front(3);
|
||||
assert(c.front() == 3);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
assert(c.front() == 1);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
c.push_front(3);
|
||||
assert(c.front() == 3);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void push_front(const value_type& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
// Flag that makes the copy constructor for CMyClass throw an exception
|
||||
static bool gCopyConstructorShouldThow = false;
|
||||
|
||||
|
||||
class CMyClass {
|
||||
public: CMyClass();
|
||||
public: CMyClass(const CMyClass& iOther);
|
||||
public: ~CMyClass();
|
||||
|
||||
private: int fMagicValue;
|
||||
|
||||
private: static int kStartedConstructionMagicValue;
|
||||
private: static int kFinishedConstructionMagicValue;
|
||||
};
|
||||
|
||||
// Value for fMagicValue when the constructor has started running, but not yet finished
|
||||
int CMyClass::kStartedConstructionMagicValue = 0;
|
||||
// Value for fMagicValue when the constructor has finished running
|
||||
int CMyClass::kFinishedConstructionMagicValue = 12345;
|
||||
|
||||
CMyClass::CMyClass() :
|
||||
fMagicValue(kStartedConstructionMagicValue)
|
||||
{
|
||||
// Signal that the constructor has finished running
|
||||
fMagicValue = kFinishedConstructionMagicValue;
|
||||
}
|
||||
|
||||
CMyClass::CMyClass(const CMyClass& /*iOther*/) :
|
||||
fMagicValue(kStartedConstructionMagicValue)
|
||||
{
|
||||
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
|
||||
if (gCopyConstructorShouldThow) {
|
||||
throw std::exception();
|
||||
}
|
||||
// Signal that the constructor has finished running
|
||||
fMagicValue = kFinishedConstructionMagicValue;
|
||||
}
|
||||
|
||||
CMyClass::~CMyClass() {
|
||||
// Only instances for which the constructor has finished running should be destructed
|
||||
assert(fMagicValue == kFinishedConstructionMagicValue);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
CMyClass instance;
|
||||
std::forward_list<CMyClass> vec;
|
||||
|
||||
vec.push_front(instance);
|
||||
|
||||
gCopyConstructorShouldThow = true;
|
||||
try {
|
||||
vec.push_front(instance);
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void push_front(value_type&& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
assert(c.front() == 1);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
c.push_front(3);
|
||||
assert(c.front() == 3);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef MoveOnly T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.push_front(1);
|
||||
assert(c.front() == 1);
|
||||
assert(distance(c.begin(), c.end()) == 1);
|
||||
c.push_front(3);
|
||||
assert(c.front() == 3);
|
||||
assert(*next(c.begin()) == 1);
|
||||
assert(distance(c.begin(), c.end()) == 2);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void resize(size_type n);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "DefaultOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
c.resize(0);
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
c.resize(10);
|
||||
assert(distance(c.begin(), c.end()) == 10);
|
||||
c.resize(20);
|
||||
assert(distance(c.begin(), c.end()) == 20);
|
||||
c.resize(5);
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
c.resize(0);
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
c.resize(3);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
c.resize(6);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 0);
|
||||
assert(*next(c.begin(), 4) == 0);
|
||||
assert(*next(c.begin(), 5) == 0);
|
||||
|
||||
c.resize(6);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 0);
|
||||
assert(*next(c.begin(), 4) == 0);
|
||||
assert(*next(c.begin(), 5) == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef DefaultOnly T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
c.resize(0);
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
c.resize(10);
|
||||
assert(distance(c.begin(), c.end()) == 10);
|
||||
c.resize(20);
|
||||
assert(distance(c.begin(), c.end()) == 20);
|
||||
c.resize(5);
|
||||
assert(distance(c.begin(), c.end()) == 5);
|
||||
c.resize(0);
|
||||
assert(distance(c.begin(), c.end()) == 0);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
c.resize(3);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
c.resize(6);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 0);
|
||||
assert(*next(c.begin(), 4) == 0);
|
||||
assert(*next(c.begin(), 5) == 0);
|
||||
|
||||
c.resize(6);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 0);
|
||||
assert(*next(c.begin(), 4) == 0);
|
||||
assert(*next(c.begin(), 5) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void resize(size_type n, const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "DefaultOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
c.resize(3, 10);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
c.resize(6, 10);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 10);
|
||||
assert(*next(c.begin(), 4) == 10);
|
||||
assert(*next(c.begin(), 5) == 10);
|
||||
|
||||
c.resize(6, 12);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 10);
|
||||
assert(*next(c.begin(), 4) == 10);
|
||||
assert(*next(c.begin(), 5) == 10);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4};
|
||||
C c(std::begin(t), std::end(t));
|
||||
|
||||
c.resize(3, 10);
|
||||
assert(distance(c.begin(), c.end()) == 3);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
|
||||
c.resize(6, 10);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 10);
|
||||
assert(*next(c.begin(), 4) == 10);
|
||||
assert(*next(c.begin(), 5) == 10);
|
||||
|
||||
c.resize(6, 12);
|
||||
assert(distance(c.begin(), c.end()) == 6);
|
||||
assert(*next(c.begin(), 0) == 0);
|
||||
assert(*next(c.begin(), 1) == 1);
|
||||
assert(*next(c.begin(), 2) == 2);
|
||||
assert(*next(c.begin(), 3) == 10);
|
||||
assert(*next(c.begin(), 4) == 10);
|
||||
assert(*next(c.begin(), 5) == 10);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void merge(forward_list&& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {3, 5, 6, 7, 12, 13};
|
||||
const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
|
||||
const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.merge(c2);
|
||||
C c3(std::begin(t3), std::end(t3));
|
||||
assert(c1 == c3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {3, 5, 6, 7, 12, 13};
|
||||
const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
|
||||
const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.merge(c2);
|
||||
C c3(std::begin(t3), std::end(t3));
|
||||
assert(c1 == c3);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class Compare> void merge(forward_list&& x, Compare comp);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {13, 12, 7, 6, 5, 3};
|
||||
const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
|
||||
const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.merge(c2, std::greater<T>());
|
||||
C c3(std::begin(t3), std::end(t3));
|
||||
assert(c1 == c3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {13, 12, 7, 6, 5, 3};
|
||||
const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
|
||||
const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.merge(c2, std::greater<T>());
|
||||
C c3(std::begin(t3), std::end(t3));
|
||||
assert(c1 == c3);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void remove(const value_type& v);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
struct S {
|
||||
S(int i) : i_(new int(i)) {}
|
||||
S(const S &rhs) : i_(new int(*rhs.i_)) {}
|
||||
S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
|
||||
~S () { delete i_; i_ = NULL; }
|
||||
bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
|
||||
int get () const { return *i_; }
|
||||
int *i_;
|
||||
};
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2;
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{ // LWG issue #526
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
int t1[] = {1, 2, 1, 3, 5, 8, 11};
|
||||
int t2[] = { 2, 3, 5, 8, 11};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(c1.front());
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef S T;
|
||||
typedef std::forward_list<T> C;
|
||||
int t1[] = {1, 2, 1, 3, 5, 8, 11, 1};
|
||||
int t2[] = { 2, 3, 5, 8, 11 };
|
||||
C c;
|
||||
for(int *ip = std::end(t1); ip != std::begin(t1);)
|
||||
c.push_front(S(*--ip));
|
||||
c.remove(c.front());
|
||||
C::const_iterator it = c.begin();
|
||||
for(int *ip = std::begin(t2); ip != std::end(t2); ++ip, ++it) {
|
||||
assert ( it != c.end());
|
||||
assert ( *ip == it->get());
|
||||
}
|
||||
assert ( it == c.end ());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2;
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.remove(0);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class Predicate> void remove_if(Predicate pred);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
#include "counting_predicates.hpp"
|
||||
|
||||
|
||||
bool g(int i)
|
||||
{
|
||||
return i < 3;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2;
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == 0);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2;
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == 0);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 5, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
Predicate cp(g);
|
||||
c1.remove_if(std::ref(cp));
|
||||
assert(c1 == c2);
|
||||
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void reverse();
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N)
|
||||
{
|
||||
C c;
|
||||
for (int i = 0; i < N; ++i)
|
||||
c.push_front(i);
|
||||
c.reverse();
|
||||
assert(distance(c.begin(), c.end()) == N);
|
||||
typename C::const_iterator j = c.begin();
|
||||
for (int i = 0; i < N; ++i, ++j)
|
||||
assert(*j == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
test<std::forward_list<int> >(i);
|
||||
#if __cplusplus >= 201103L
|
||||
for (int i = 0; i < 10; ++i)
|
||||
test<std::forward_list<int, min_allocator<int>> >(i);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void sort();
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N)
|
||||
{
|
||||
typedef typename C::value_type T;
|
||||
typedef std::vector<T> V;
|
||||
V v;
|
||||
for (int i = 0; i < N; ++i)
|
||||
v.push_back(i);
|
||||
std::random_shuffle(v.begin(), v.end());
|
||||
C c(v.begin(), v.end());
|
||||
c.sort();
|
||||
assert(distance(c.begin(), c.end()) == N);
|
||||
typename C::const_iterator j = c.begin();
|
||||
for (int i = 0; i < N; ++i, ++j)
|
||||
assert(*j == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i < 40; ++i)
|
||||
test<std::forward_list<int> >(i);
|
||||
#if __cplusplus >= 201103L
|
||||
for (int i = 0; i < 40; ++i)
|
||||
test<std::forward_list<int, min_allocator<int>> >(i);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class Compare> void sort(Compare comp);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N)
|
||||
{
|
||||
typedef typename C::value_type T;
|
||||
typedef std::vector<T> V;
|
||||
V v;
|
||||
for (int i = 0; i < N; ++i)
|
||||
v.push_back(i);
|
||||
std::random_shuffle(v.begin(), v.end());
|
||||
C c(v.begin(), v.end());
|
||||
c.sort(std::greater<T>());
|
||||
assert(distance(c.begin(), c.end()) == N);
|
||||
typename C::const_iterator j = c.begin();
|
||||
for (int i = 0; i < N; ++i, ++j)
|
||||
assert(*j == N-1-i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i < 40; ++i)
|
||||
test<std::forward_list<int> >(i);
|
||||
#if __cplusplus >= 201103L
|
||||
for (int i = 0; i < 40; ++i)
|
||||
test<std::forward_list<int, min_allocator<int>> >(i);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void splice_after(const_iterator p, forward_list&& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
typedef int T;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
const T t2[] = {10, 11, 12, 13, 14, 15};
|
||||
const int size_t1 = std::end(t1) - std::begin(t1);
|
||||
const int size_t2 = std::end(t2) - std::begin(t2);
|
||||
|
||||
template <class C>
|
||||
void
|
||||
testd(const C& c, int p, int l)
|
||||
{
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n1 = 0;
|
||||
for (; n1 < p; ++n1, ++i)
|
||||
assert(*i == t1[n1]);
|
||||
for (int n2 = 0; n2 < l; ++n2, ++i)
|
||||
assert(*i == t2[n2]);
|
||||
for (; n1 < size_t1; ++n1, ++i)
|
||||
assert(*i == t1[n1]);
|
||||
assert(distance(c.begin(), c.end()) == size_t1 + l);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T> C;
|
||||
for (int l = 0; l <= size_t2; ++l)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(t2, t2+l);
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
|
||||
testd(c1, p, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
for (int l = 0; l <= size_t2; ++l)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(t2, t2+l);
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
|
||||
testd(c1, p, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,140 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void splice_after(const_iterator p, forward_list&& x, const_iterator i);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
typedef int T;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
const T t2[] = {10, 11, 12};
|
||||
const int size_t1 = std::end(t1) - std::begin(t1);
|
||||
const int size_t2 = std::end(t2) - std::begin(t2);
|
||||
|
||||
template <class C>
|
||||
void
|
||||
testd(const C& c, int p, int f)
|
||||
{
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n1 = 0;
|
||||
for (; n1 < p; ++n1, ++i)
|
||||
assert(*i == t1[n1]);
|
||||
for (int n2 = f; n2 < f+1; ++n2, ++i)
|
||||
assert(*i == t2[n2]);
|
||||
for (; n1 < size_t1; ++n1, ++i)
|
||||
assert(*i == t1[n1]);
|
||||
assert(distance(c.begin(), c.end()) == size_t1 + 1);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void
|
||||
tests(const C& c, int p, int f)
|
||||
{
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n = 0;
|
||||
int d = 1;
|
||||
if (p == f || p == f+1)
|
||||
{
|
||||
for (n = 0; n < size_t1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
}
|
||||
else if (p < f)
|
||||
{
|
||||
for (n = 0; n < p; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = f; n < f+1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = p; n < f; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = f+1; n < size_t1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
}
|
||||
else // p > f+1
|
||||
{
|
||||
for (n = 0; n < f; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = f+1; n < p; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = f; n < f+1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = p; n < size_t1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
}
|
||||
assert(distance(c.begin(), c.end()) == size_t1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T> C;
|
||||
for (int f = 0; f <= size_t2-1; ++f)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
|
||||
next(c2.cbefore_begin(), f));
|
||||
testd(c1, p, f);
|
||||
}
|
||||
}
|
||||
|
||||
// splicing within same container
|
||||
for (int f = 0; f <= size_t1-1; ++f)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
|
||||
next(c1.cbefore_begin(), f));
|
||||
tests(c1, p, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
for (int f = 0; f <= size_t2-1; ++f)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
|
||||
next(c2.cbefore_begin(), f));
|
||||
testd(c1, p, f);
|
||||
}
|
||||
}
|
||||
|
||||
// splicing within same container
|
||||
for (int f = 0; f <= size_t1-1; ++f)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
|
||||
next(c1.cbefore_begin(), f));
|
||||
tests(c1, p, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,169 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void splice_after(const_iterator p, forward_list&& x,
|
||||
// const_iterator first, const_iterator last);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
typedef int T;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
const T t2[] = {10, 11, 12, 13, 14, 15};
|
||||
const int size_t1 = std::end(t1) - std::begin(t1);
|
||||
const int size_t2 = std::end(t2) - std::begin(t2);
|
||||
|
||||
template <class C>
|
||||
void
|
||||
testd(const C& c, int p, int f, int l)
|
||||
{
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n1 = 0;
|
||||
for (; n1 < p; ++n1, ++i)
|
||||
assert(*i == t1[n1]);
|
||||
for (int n2 = f; n2 < l-1; ++n2, ++i)
|
||||
assert(*i == t2[n2]);
|
||||
for (; n1 < size_t1; ++n1, ++i)
|
||||
assert(*i == t1[n1]);
|
||||
assert(distance(c.begin(), c.end()) == size_t1 + (l > f+1 ? l-1-f : 0));
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void
|
||||
tests(const C& c, int p, int f, int l)
|
||||
{
|
||||
typename C::const_iterator i = c.begin();
|
||||
int n = 0;
|
||||
int d = l > f+1 ? l-1-f : 0;
|
||||
if (d == 0 || p == f)
|
||||
{
|
||||
for (n = 0; n < size_t1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
}
|
||||
else if (p < f)
|
||||
{
|
||||
for (n = 0; n < p; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = f; n < l-1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = p; n < f; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = l-1; n < size_t1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
}
|
||||
else // p > f
|
||||
{
|
||||
for (n = 0; n < f; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = l-1; n < p; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = f; n < l-1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
for (n = p; n < size_t1; ++n, ++i)
|
||||
assert(*i == t1[n]);
|
||||
}
|
||||
assert(distance(c.begin(), c.end()) == size_t1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T> C;
|
||||
for (int f = 0; f <= size_t2+1; ++f)
|
||||
{
|
||||
for (int l = f; l <= size_t2+1; ++l)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
|
||||
next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
|
||||
testd(c1, p, f, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// splicing within same container
|
||||
for (int f = 0; f <= size_t1+1; ++f)
|
||||
{
|
||||
for (int l = f; l <= size_t1; ++l)
|
||||
{
|
||||
for (int p = 0; p <= f; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
|
||||
next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
|
||||
tests(c1, p, f, l);
|
||||
}
|
||||
for (int p = l; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
|
||||
next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
|
||||
tests(c1, p, f, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
// splicing different containers
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
for (int f = 0; f <= size_t2+1; ++f)
|
||||
{
|
||||
for (int l = f; l <= size_t2+1; ++l)
|
||||
{
|
||||
for (int p = 0; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
|
||||
next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
|
||||
testd(c1, p, f, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// splicing within same container
|
||||
for (int f = 0; f <= size_t1+1; ++f)
|
||||
{
|
||||
for (int l = f; l <= size_t1; ++l)
|
||||
{
|
||||
for (int p = 0; p <= f; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
|
||||
next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
|
||||
tests(c1, p, f, l);
|
||||
}
|
||||
for (int p = l; p <= size_t1; ++p)
|
||||
{
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
|
||||
c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
|
||||
next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
|
||||
tests(c1, p, f, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,120 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void unique();
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {0, 5, 0, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
const T t2[] = {0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {0, 5, 0, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
const T t2[] = {0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique();
|
||||
assert(c1 == c2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
bool g(int x, int y)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {0, 5, 0, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
const T t2[] = {0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
|
||||
const T t2[] = {0, 5, 0, 5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {0, 0, 0, 0};
|
||||
const T t2[] = {0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5};
|
||||
const T t2[] = {5};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
const T t1[] = {5, 5, 5, 0};
|
||||
const T t2[] = {5, 0};
|
||||
C c1(std::begin(t1), std::end(t1));
|
||||
C c2(std::begin(t2), std::end(t2));
|
||||
c1.unique(g);
|
||||
assert(c1 == c2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class T, class Allocator>
|
||||
// bool operator==(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator!=(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N, int M)
|
||||
{
|
||||
typedef typename C::value_type T;
|
||||
C c1;
|
||||
for (int i = 0; i < N; ++i)
|
||||
c1.push_front(i);
|
||||
C c2;
|
||||
for (int i = 0; i < M; ++i)
|
||||
c2.push_front(i);
|
||||
if (N == M)
|
||||
assert(c1 == c2);
|
||||
else
|
||||
assert(c1 != c2);
|
||||
c2 = c1;
|
||||
assert(c1 == c2);
|
||||
if (N > 0)
|
||||
{
|
||||
c2.front() = N+1;
|
||||
assert(c1 != c2);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int j = 0; j < 10; ++j)
|
||||
test<std::forward_list<int> >(i, j);
|
||||
#if __cplusplus >= 201103L
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int j = 0; j < 10; ++j)
|
||||
test<std::forward_list<int, min_allocator<int>> >(i, j);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,259 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void swap(forward_list& x);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
C c2(A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
C c2(A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
C c2(A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
C c2(A(2));
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A());
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A());
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A());
|
||||
C c2(A{});
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A{});
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A());
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A{});
|
||||
C c2(A{});
|
||||
c1.swap(c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,260 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class T, class Allocator>
|
||||
// void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y);
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
C c2(A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef test_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
C c2(A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(1));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(2));
|
||||
}
|
||||
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A(1));
|
||||
C c2(A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef other_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A(1));
|
||||
C c2(A(2));
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A(2));
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A());
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A());
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
const T t1[] = {0, 1, 2, 3, 4, 5};
|
||||
C c1(std::begin(t1), std::end(t1), A());
|
||||
C c2(A{});
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 6);
|
||||
assert(*next(c2.begin(), 0) == 0);
|
||||
assert(*next(c2.begin(), 1) == 1);
|
||||
assert(*next(c2.begin(), 2) == 2);
|
||||
assert(*next(c2.begin(), 3) == 3);
|
||||
assert(*next(c2.begin(), 4) == 4);
|
||||
assert(*next(c2.begin(), 5) == 5);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A{});
|
||||
const T t2[] = {10, 11, 12};
|
||||
C c2(std::begin(t2), std::end(t2), A());
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 3);
|
||||
assert(*next(c1.begin(), 0) == 10);
|
||||
assert(*next(c1.begin(), 1) == 11);
|
||||
assert(*next(c1.begin(), 2) == 12);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef min_allocator<T> A;
|
||||
typedef std::forward_list<T, A> C;
|
||||
C c1(A{});
|
||||
C c2(A{});
|
||||
swap(c1, c2);
|
||||
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c1.get_allocator() == A());
|
||||
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class T, class Allocator>
|
||||
// bool operator< (const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator> (const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator>=(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
//
|
||||
// template <class T, class Allocator>
|
||||
// bool operator<=(const forward_list<T, Allocator>& x,
|
||||
// const forward_list<T, Allocator>& y);
|
||||
|
||||
#include <forward_list>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void test(int N, int M)
|
||||
{
|
||||
typedef typename C::value_type T;
|
||||
C c1;
|
||||
for (int i = 0; i < N; ++i)
|
||||
c1.push_front(i);
|
||||
C c2;
|
||||
for (int i = 0; i < M; ++i)
|
||||
c2.push_front(i);
|
||||
if (N < M)
|
||||
assert(c1 < c2);
|
||||
if (N <= M)
|
||||
assert(c1 <= c2);
|
||||
if (N >= M)
|
||||
assert(c1 >= c2);
|
||||
if (N > M)
|
||||
assert(c1 > c2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int j = 0; j < 10; ++j)
|
||||
test<std::forward_list<int> >(i, j);
|
||||
#if __cplusplus >= 201103L
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int j = 0; j < 10; ++j)
|
||||
test<std::forward_list<int, min_allocator<int>> >(i, j);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// void swap(forward_list& c)
|
||||
// noexcept(!allocator_type::propagate_on_container_swap::value ||
|
||||
// __is_nothrow_swappable<allocator_type>::value);
|
||||
|
||||
// This tests a conforming extension
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
struct some_alloc
|
||||
{
|
||||
typedef T value_type;
|
||||
|
||||
some_alloc() {}
|
||||
some_alloc(const some_alloc&);
|
||||
void deallocate(void*, unsigned) {}
|
||||
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::forward_list<MoveOnly> C;
|
||||
C c1, c2;
|
||||
static_assert(noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
|
||||
C c1, c2;
|
||||
static_assert(noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
|
||||
C c1, c2;
|
||||
static_assert(noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
{
|
||||
typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
|
||||
C c1, c2;
|
||||
static_assert(!noexcept(swap(c1, c2)), "");
|
||||
}
|
||||
#endif
|
||||
}
|
35
test/std/containers/sequences/forwardlist/max_size.pass.cpp
Normal file
35
test/std/containers/sequences/forwardlist/max_size.pass.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// size_type max_size() const;
|
||||
|
||||
#include <forward_list>
|
||||
#include <cassert>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T> C;
|
||||
C c;
|
||||
assert(c.max_size() > 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::forward_list<T, min_allocator<T>> C;
|
||||
C c;
|
||||
assert(c.max_size() > 0);
|
||||
}
|
||||
#endif
|
||||
}
|
60
test/std/containers/sequences/forwardlist/types.pass.cpp
Normal file
60
test/std/containers/sequences/forwardlist/types.pass.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// template <class T, class Allocator = allocator<T>>
|
||||
// class forward_list
|
||||
// {
|
||||
// public:
|
||||
// typedef T value_type;
|
||||
// typedef Allocator allocator_type;
|
||||
//
|
||||
// typedef value_type& reference;
|
||||
// typedef const value_type& const_reference;
|
||||
// typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
// typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
// ...
|
||||
// };
|
||||
|
||||
#include <forward_list>
|
||||
#include <type_traits>
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::forward_list<char> C;
|
||||
static_assert((std::is_same<C::value_type, char>::value), "");
|
||||
static_assert((std::is_same<C::allocator_type, std::allocator<char> >::value), "");
|
||||
static_assert((std::is_same<C::reference, char&>::value), "");
|
||||
static_assert((std::is_same<C::const_reference, const char&>::value), "");
|
||||
static_assert((std::is_same<C::pointer, char*>::value), "");
|
||||
static_assert((std::is_same<C::const_pointer, const char*>::value), "");
|
||||
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
|
||||
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::forward_list<char, min_allocator<char>> C;
|
||||
static_assert((std::is_same<C::value_type, char>::value), "");
|
||||
static_assert((std::is_same<C::allocator_type, min_allocator<char> >::value), "");
|
||||
static_assert((std::is_same<C::reference, char&>::value), "");
|
||||
static_assert((std::is_same<C::const_reference, const char&>::value), "");
|
||||
static_assert((std::is_same<C::pointer, min_pointer<char>>::value), "");
|
||||
static_assert((std::is_same<C::const_pointer, min_pointer<const char>>::value), "");
|
||||
// min_allocator doesn't have a size_type, so one gets synthesized
|
||||
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
|
||||
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
|
||||
}
|
||||
#endif
|
||||
}
|
20
test/std/containers/sequences/forwardlist/version.pass.cpp
Normal file
20
test/std/containers/sequences/forwardlist/version.pass.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user