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:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// explicit back_insert_iterator(Cont& x);
// test for explicit
#include <iterator>
#include <vector>
int main()
{
std::back_insert_iterator<std::vector<int> > i = std::vector<int>();
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// explicit back_insert_iterator(Cont& x);
#include <iterator>
#include <vector>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::back_insert_iterator<C> i(c);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// back_insert_iterator<Cont> operator++(int);
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::back_insert_iterator<C> i(c);
std::back_insert_iterator<C> r = i++;
r = 0;
assert(c.size() == 1);
assert(c.back() == 0);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// back_insert_iterator<Cont>& operator++();
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::back_insert_iterator<C> i(c);
std::back_insert_iterator<C>& r = ++i;
assert(&r == &i);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// requires CopyConstructible<Cont::value_type>
// back_insert_iterator<Cont>&
// operator=(const Cont::value_type& value);
#include <iterator>
#include <vector>
#include <cassert>
template <class C>
void
test(C c)
{
const typename C::value_type v = typename C::value_type();
std::back_insert_iterator<C> i(c);
i = v;
assert(c.back() == v);
}
class Copyable
{
int data_;
public:
Copyable() : data_(0) {}
~Copyable() {data_ = -1;}
friend bool operator==(const Copyable& x, const Copyable& y)
{return x.data_ == y.data_;}
};
int main()
{
test(std::vector<Copyable>());
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// requires CopyConstructible<Cont::value_type>
// back_insert_iterator<Cont>&
// operator=(Cont::value_type&& value);
#include <iterator>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <vector>
#include <memory>
#include <cassert>
template <class C>
void
test(C c)
{
std::back_insert_iterator<C> i(c);
i = typename C::value_type();
assert(c.back() == typename C::value_type());
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test(std::vector<std::unique_ptr<int> >());
#endif
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// back_insert_iterator<Cont>& operator*();
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::back_insert_iterator<C> i(c);
std::back_insert_iterator<C>& r = *i;
assert(&r == &i);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// template <BackInsertionContainer Cont>
// back_insert_iterator<Cont>
// back_inserter(Cont& x);
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::back_insert_iterator<C> i = std::back_inserter(c);
i = 0;
assert(c.size() == 1);
assert(c.back() == 0);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// back_insert_iterator
// Test nested types and data member:
// template <BackInsertionContainer Cont>
// class back_insert_iterator {
// protected:
// Cont* container;
// public:
// typedef Cont container_type;
// typedef void value_type;
// typedef void difference_type;
// typedef back_insert_iterator<Cont>& reference;
// typedef void pointer;
// };
#include <iterator>
#include <type_traits>
#include <vector>
template <class C>
struct find_container
: private std::back_insert_iterator<C>
{
explicit find_container(C& c) : std::back_insert_iterator<C>(c) {}
void test() {this->container = 0;}
};
template <class C>
void
test()
{
typedef std::back_insert_iterator<C> R;
C c;
find_container<C> q(c);
q.test();
static_assert((std::is_same<typename R::container_type, C>::value), "");
static_assert((std::is_same<typename R::value_type, void>::value), "");
static_assert((std::is_same<typename R::difference_type, void>::value), "");
static_assert((std::is_same<typename R::reference, R&>::value), "");
static_assert((std::is_same<typename R::pointer, void>::value), "");
static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
}
int main()
{
test<std::vector<int> >();
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// explicit front_insert_iterator(Cont& x);
// test for explicit
#include <iterator>
#include <list>
int main()
{
std::front_insert_iterator<std::list<int> > i = std::list<int>();
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// explicit front_insert_iterator(Cont& x);
#include <iterator>
#include <list>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::front_insert_iterator<C> i(c);
}
int main()
{
test(std::list<int>());
test(nasty_list<int>());
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// front_insert_iterator<Cont> operator++(int);
#include <iterator>
#include <list>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::front_insert_iterator<C> i(c);
std::front_insert_iterator<C> r = i++;
r = 0;
assert(c.size() == 1);
assert(c.back() == 0);
}
int main()
{
test(std::list<int>());
test(nasty_list<int>());
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// front_insert_iterator<Cont>& operator++();
#include <iterator>
#include <list>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::front_insert_iterator<C> i(c);
std::front_insert_iterator<C>& r = ++i;
assert(&r == &i);
}
int main()
{
test(std::list<int>());
test(nasty_list<int>());
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// front_insert_iterator<Cont>&
// operator=(const Cont::value_type& value);
#include <iterator>
#include <list>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
const typename C::value_type v = typename C::value_type();
std::front_insert_iterator<C> i(c);
i = v;
assert(c.front() == v);
}
class Copyable
{
int data_;
public:
Copyable() : data_(0) {}
~Copyable() {data_ = -1;}
friend bool operator==(const Copyable& x, const Copyable& y)
{return x.data_ == y.data_;}
};
int main()
{
test(std::list<Copyable>());
test(nasty_list<Copyable>());
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// front_insert_iterator<Cont>&
// operator=(Cont::value_type&& value);
#include <iterator>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <list>
#include <memory>
#include <cassert>
template <class C>
void
test(C c)
{
std::front_insert_iterator<C> i(c);
i = typename C::value_type();
assert(c.front() == typename C::value_type());
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test(std::list<std::unique_ptr<int> >());
#endif
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// front_insert_iterator<Cont>& operator*();
#include <iterator>
#include <list>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::front_insert_iterator<C> i(c);
std::front_insert_iterator<C>& r = *i;
assert(&r == &i);
}
int main()
{
test(std::list<int>());
test(nasty_list<int>());
}

View 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// template <BackInsertionContainer Cont>
// front_insert_iterator<Cont>
// front_inserter(Cont& x);
#include <iterator>
#include <list>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::front_insert_iterator<C> i = std::front_inserter(c);
i = 0;
assert(c.size() == 1);
assert(c.front() == 0);
}
int main()
{
test(std::list<int>());
test(nasty_list<int>());
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// front_insert_iterator
// Test nested types and data member:
// template <class Container>
// class front_insert_iterator {
// protected:
// Container* container;
// public:
// typedef Container container_type;
// typedef void value_type;
// typedef void difference_type;
// typedef front_insert_iterator<Cont>& reference;
// typedef void pointer;
// typedef output_iterator_tag iterator_category;
// };
#include <iterator>
#include <type_traits>
#include <vector>
template <class C>
struct find_container
: private std::front_insert_iterator<C>
{
explicit find_container(C& c) : std::front_insert_iterator<C>(c) {}
void test() {this->container = 0;}
};
template <class C>
void
test()
{
typedef std::front_insert_iterator<C> R;
C c;
find_container<C> q(c);
q.test();
static_assert((std::is_same<typename R::container_type, C>::value), "");
static_assert((std::is_same<typename R::value_type, void>::value), "");
static_assert((std::is_same<typename R::difference_type, void>::value), "");
static_assert((std::is_same<typename R::reference, R&>::value), "");
static_assert((std::is_same<typename R::pointer, void>::value), "");
static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
}
int main()
{
test<std::vector<int> >();
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// insert_iterator(Cont& x, Cont::iterator i);
#include <iterator>
#include <vector>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::insert_iterator<C> i(c, c.begin());
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// insert_iterator<Cont> operator++(int);
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::insert_iterator<C> i(c, c.end());
std::insert_iterator<C> r = i++;
r = 0;
assert(c.size() == 1);
assert(c.back() == 0);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// insert_iterator<Cont>& operator++();
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::insert_iterator<C> i(c, c.end());
std::insert_iterator<C>& r = ++i;
assert(&r == &i);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// requires CopyConstructible<Cont::value_type>
// insert_iterator<Cont>&
// operator=(const Cont::value_type& value);
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c1, typename C::difference_type j,
typename C::value_type x1, typename C::value_type x2,
typename C::value_type x3, const C& c2)
{
std::insert_iterator<C> q(c1, c1.begin() + j);
q = x1;
q = x2;
q = x3;
assert(c1 == c2);
}
template <class C>
void
insert3at(C& c, typename C::iterator i,
typename C::value_type x1, typename C::value_type x2,
typename C::value_type x3)
{
i = c.insert(i, x1);
i = c.insert(++i, x2);
c.insert(++i, x3);
}
int main()
{
{
typedef std::vector<int> C;
C c1;
for (int i = 0; i < 3; ++i)
c1.push_back(i);
C c2 = c1;
insert3at(c2, c2.begin(), 'a', 'b', 'c');
test(c1, 0, 'a', 'b', 'c', c2);
c2 = c1;
insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
test(c1, 1, 'a', 'b', 'c', c2);
c2 = c1;
insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
test(c1, 2, 'a', 'b', 'c', c2);
c2 = c1;
insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
test(c1, 3, 'a', 'b', 'c', c2);
}
{
typedef nasty_vector<int> C;
C c1;
for (int i = 0; i < 3; ++i)
c1.push_back(i);
C c2 = c1;
insert3at(c2, c2.begin(), 'a', 'b', 'c');
test(c1, 0, 'a', 'b', 'c', c2);
c2 = c1;
insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
test(c1, 1, 'a', 'b', 'c', c2);
c2 = c1;
insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
test(c1, 2, 'a', 'b', 'c', c2);
c2 = c1;
insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
test(c1, 3, 'a', 'b', 'c', c2);
}
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// requires CopyConstructible<Cont::value_type>
// insert_iterator<Cont>&
// operator=(const Cont::value_type& value);
#include <iterator>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <vector>
#include <memory>
#include <cassert>
template <class C>
void
test(C c1, typename C::difference_type j,
typename C::value_type x1, typename C::value_type x2,
typename C::value_type x3, const C& c2)
{
std::insert_iterator<C> q(c1, c1.begin() + j);
q = std::move(x1);
q = std::move(x2);
q = std::move(x3);
assert(c1 == c2);
}
template <class C>
void
insert3at(C& c, typename C::iterator i,
typename C::value_type x1, typename C::value_type x2,
typename C::value_type x3)
{
i = c.insert(i, std::move(x1));
i = c.insert(++i, std::move(x2));
c.insert(++i, std::move(x3));
}
struct do_nothing
{
void operator()(void*) const {}
};
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unique_ptr<int, do_nothing> Ptr;
typedef std::vector<Ptr> C;
C c1;
int x[6] = {0};
for (int i = 0; i < 3; ++i)
c1.push_back(Ptr(x+i));
C c2;
for (int i = 0; i < 3; ++i)
c2.push_back(Ptr(x+i));
insert3at(c2, c2.begin(), Ptr(x+3), Ptr(x+4), Ptr(x+5));
test(std::move(c1), 0, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
c1.clear();
for (int i = 0; i < 3; ++i)
c1.push_back(Ptr(x+i));
c2.clear();
for (int i = 0; i < 3; ++i)
c2.push_back(Ptr(x+i));
insert3at(c2, c2.begin()+1, Ptr(x+3), Ptr(x+4), Ptr(x+5));
test(std::move(c1), 1, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
c1.clear();
for (int i = 0; i < 3; ++i)
c1.push_back(Ptr(x+i));
c2.clear();
for (int i = 0; i < 3; ++i)
c2.push_back(Ptr(x+i));
insert3at(c2, c2.begin()+2, Ptr(x+3), Ptr(x+4), Ptr(x+5));
test(std::move(c1), 2, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
c1.clear();
for (int i = 0; i < 3; ++i)
c1.push_back(Ptr(x+i));
c2.clear();
for (int i = 0; i < 3; ++i)
c2.push_back(Ptr(x+i));
insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5));
test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// insert_iterator<Cont>& operator*();
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::insert_iterator<C> i(c, c.end());
std::insert_iterator<C>& r = *i;
assert(&r == &i);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// template <InsertionContainer Cont>
// insert_iterator<Cont>
// inserter(Cont& x, Cont::iterator i);
#include <iterator>
#include <vector>
#include <cassert>
#include "nasty_containers.hpp"
template <class C>
void
test(C c)
{
std::insert_iterator<C> i = std::inserter(c, c.end());
i = 0;
assert(c.size() == 1);
assert(c.back() == 0);
}
int main()
{
test(std::vector<int>());
test(nasty_vector<int>());
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <iterator>
// insert_iterator
// Test nested types and data members:
// template <InsertionContainer Cont>
// class insert_iterator {
// protected:
// Cont* container;
// Cont::iterator iter;
// public:
// typedef Cont container_type;
// typedef void value_type;
// typedef void difference_type;
// typedef insert_iterator<Cont>& reference;
// typedef void pointer;
// };
#include <iterator>
#include <type_traits>
#include <vector>
template <class C>
struct find_members
: private std::insert_iterator<C>
{
explicit find_members(C& c) : std::insert_iterator<C>(c, c.begin()) {}
void test()
{
this->container = 0;
(void)(this->iter == this->iter);
}
};
template <class C>
void
test()
{
typedef std::insert_iterator<C> R;
C c;
find_members<C> q(c);
q.test();
static_assert((std::is_same<typename R::container_type, C>::value), "");
static_assert((std::is_same<typename R::value_type, void>::value), "");
static_assert((std::is_same<typename R::difference_type, void>::value), "");
static_assert((std::is_same<typename R::reference, R&>::value), "");
static_assert((std::is_same<typename R::pointer, void>::value), "");
static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
}
int main()
{
test<std::vector<int> >();
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}