libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-05-11 19:42:16 +00:00
commit bc8d3f97eb
3893 changed files with 1209942 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// reference front();
// const_reference front() const;
#include <forward_list>
#include <cassert>
#include <iterator>
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);
}
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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());
}
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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());
}
}

View File

@@ -0,0 +1,119 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
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));
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void assign(initializer_list<value_type> il);
#include <forward_list>
#include <cassert>
#include <iterator>
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,162 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
int main()
{
#ifdef _LIBCPP_MOVE
{
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());
}
#endif
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list& operator=(initializer_list<value_type> il);
#include <forward_list>
#include <cassert>
#include <iterator>
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// template <class InputIterator>
// void assign(InputIterator first, InputIterator last);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "../../../iterators.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);
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void assign(size_type n, const value_type& v);
#include <forward_list>
#include <cassert>
#include <iterator>
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);
}
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list(const forward_list& x);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "../../../test_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
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
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));
}
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list();
#include <forward_list>
#include <cassert>
int main()
{
{
typedef int T;
typedef std::forward_list<T> C;
C c;
assert(c.empty());
}
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list(initializer_list<value_type> il);
#include <forward_list>
#include <cassert>
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
int main()
{
#ifdef _LIBCPP_MOVE
{
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));
}
#endif
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
int main()
{
#ifdef _LIBCPP_MOVE
{
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));
}
#endif
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
int main()
{
#ifdef _LIBCPP_MOVE
{
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));
}
#endif
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// template <class InputIterator>
// forward_list(InputIterator first, InputIterator last);
#include <forward_list>
#include <cassert>
#include <iterator>
#include "../../../iterators.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));
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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 "../../../iterators.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));
}
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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)
#ifdef _LIBCPP_MOVE
assert(*i == T());
#else
;
#endif
assert(n == N);
}
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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)
#ifdef _LIBCPP_MOVE
assert(*i == T());
#else
;
#endif
assert(n == N);
}
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// forward_list(size_type n, const value_type& v);
#include <forward_list>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
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));
}
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
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);
}
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
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;
}
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void clear();
#include <forward_list>
#include <cassert>
#include "../../../NotConstructible.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);
}
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// template <class... Args> void emplace_front(Args&&... args);
#include <forward_list>
#include <cassert>
#include "../../../Emplaceable.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,78 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void erase_after(const_iterator first, const_iterator last);
#include <forward_list>
#include <cassert>
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.erase_after(next(c.cbefore_begin(), 4), 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);
c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
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);
c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
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);
c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
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);
c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
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);
c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
assert(distance(c.begin(), c.end()) == 0);
}
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void erase_after(const_iterator p);
#include <forward_list>
#include <cassert>
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.erase_after(next(c.cbefore_begin(), 4));
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);
c.erase_after(next(c.cbefore_begin(), 0));
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);
c.erase_after(next(c.cbefore_begin(), 1));
assert(distance(c.begin(), c.end()) == 2);
assert(*next(c.begin(), 0) == 1);
assert(*next(c.begin(), 1) == 3);
c.erase_after(next(c.cbefore_begin(), 1));
assert(distance(c.begin(), c.end()) == 1);
assert(*next(c.begin(), 0) == 1);
c.erase_after(next(c.cbefore_begin(), 0));
assert(distance(c.begin(), c.end()) == 0);
}
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// iterator insert_after(const_iterator p, const value_type& v);
#include <forward_list>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// iterator insert_after(const_iterator p, initializer_list<value_type> il);
#include <forward_list>
#include <cassert>
int main()
{
#ifdef _LIBCPP_MOVE
{
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 == c.before_begin());
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 == c.begin());
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
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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 "../../../iterators.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 == c.before_begin());
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 == c.begin());
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);
}
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// iterator insert_after(const_iterator p, value_type&& v);
#include <forward_list>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
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 == c.before_begin());
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 == c.begin());
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);
}
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void pop_front();
#include <forward_list>
#include <cassert>
#include "../../../MoveOnly.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);
}
#ifdef _LIBCPP_MOVE
{
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
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void push_front(const value_type& v);
#include <forward_list>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void push_front(value_type&& v);
#include <forward_list>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
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);
}
#endif
}

View File

@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void resize(size_type n);
#include <forward_list>
#include <cassert>
#include "../../../DefaultOnly.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);
}
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void resize(size_type n, const value_type& v);
#include <forward_list>
#include <cassert>
#include "../../../DefaultOnly.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);
}
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void merge(forward_list&& x);
#include <forward_list>
#include <iterator>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
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);
}
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void remove(const value_type& v);
#include <forward_list>
#include <iterator>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// template <class Predicate> void remove_if(Predicate pred);
#include <forward_list>
#include <iterator>
#include <cassert>
bool g(int i)
{
return i < 3;
}
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_if(g);
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_if(g);
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_if(g);
assert(c1 == c2);
}
{
typedef int T;
typedef std::forward_list<T> C;
C c1;
C c2;
c1.remove_if(g);
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_if(g);
assert(c1 == c2);
}
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void reverse();
#include <forward_list>
#include <iterator>
#include <algorithm>
#include <cassert>
void test(int N)
{
typedef int T;
typedef std::forward_list<T> C;
C c;
for (int i = 0; i < N; ++i)
c.push_front(i);
c.reverse();
assert(distance(c.begin(), c.end()) == N);
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(i);
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void sort();
#include <forward_list>
#include <iterator>
#include <algorithm>
#include <vector>
#include <cassert>
void test(int N)
{
typedef int T;
typedef std::forward_list<T> C;
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);
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(i);
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
void test(int N)
{
typedef int T;
typedef std::forward_list<T> C;
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);
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(i);
}

View File

@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void splice_after(const_iterator p, forward_list&& x);
#include <forward_list>
#include <cassert>
#include <iterator>
typedef int T;
typedef std::forward_list<T> C;
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);
void
testd(const C& c, int p, int l)
{
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
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);
}
}
}

View File

@@ -0,0 +1,103 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
typedef int T;
typedef std::forward_list<T> C;
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);
void
testd(const C& c, int p, int f)
{
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);
}
void
tests(const C& c, int p, int f)
{
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
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);
}
}
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
typedef int T;
typedef std::forward_list<T> C;
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);
void
testd(const C& c, int p, int f, int l)
{
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));
}
void
tests(const C& c, int p, int f, int l)
{
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
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);
}
}
}
}

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void unique();
#include <forward_list>
#include <iterator>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
#include <forward_list>
#include <iterator>
#include <cassert>
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);
}
}

View File

@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
void test(int N, int M)
{
typedef int T;
typedef std::forward_list<T> C;
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(i, j);
}

View File

@@ -0,0 +1,178 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// void swap(forward_list& x);
#include <forward_list>
#include <cassert>
#include "../../../test_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));
}
}

View File

@@ -0,0 +1,179 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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"
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));
}
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
void test(int N, int M)
{
typedef int T;
typedef std::forward_list<T> C;
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(i, j);
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
// size_type max_size() const;
#include <forward_list>
#include <cassert>
int main()
{
{
typedef int T;
typedef std::forward_list<T> C;
C c;
assert(c.max_size() > 0);
}
}

View File

@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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>
int main()
{
static_assert((std::is_same<std::forward_list<char>::value_type, char>::value), "");
static_assert((std::is_same<std::forward_list<char>::allocator_type, std::allocator<char> >::value), "");
static_assert((std::is_same<std::forward_list<char>::reference, char&>::value), "");
static_assert((std::is_same<std::forward_list<char>::const_reference, const char&>::value), "");
static_assert((std::is_same<std::forward_list<char>::pointer, char*>::value), "");
static_assert((std::is_same<std::forward_list<char>::const_pointer, const char*>::value), "");
static_assert((std::is_same<std::forward_list<char>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::forward_list<char>::difference_type, std::ptrdiff_t>::value), "");
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <forward_list>
#include <forward_list>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}