Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,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>();
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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> >();
|
||||
}
|
@@ -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>();
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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> >();
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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>());
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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> >();
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <InputIterator Iter>
|
||||
// move_iterator<Iter>
|
||||
// make_move_iterator(const Iter& i);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
const std::move_iterator<It> r(i);
|
||||
assert(std::make_move_iterator(i) == r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(input_iterator<char*>(s+5));
|
||||
test(forward_iterator<char*>(s+5));
|
||||
test(bidirectional_iterator<char*>(s+5));
|
||||
test(random_access_iterator<char*>(s+5));
|
||||
test(s+5);
|
||||
}
|
||||
{
|
||||
int a[] = {1,2,3,4};
|
||||
std::make_move_iterator(a+4);
|
||||
std::make_move_iterator(a); // test for LWG issue 2061
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasMinus<Iter1, Iter2>
|
||||
// auto
|
||||
// operator-(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y)
|
||||
// -> decltype(x.base() - y.base());
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, typename std::iterator_traits<It>::difference_type x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert(r1 - r2 == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s+5), random_access_iterator<char*>(s), 5);
|
||||
test(s+5, s, 5);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter>
|
||||
// move_iterator<Iter>
|
||||
// operator+(Iter::difference_type n, const move_iterator<Iter>& x);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
const std::move_iterator<It> r(i);
|
||||
std::move_iterator<It> rr = n + r;
|
||||
assert(rr.base() == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s+5), 5, random_access_iterator<char*>(s+10));
|
||||
test(s+5, 5, s+10);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// move_iterator operator+(difference_type n) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
const std::move_iterator<It> r(i);
|
||||
std::move_iterator<It> rr = r + n;
|
||||
assert(rr.base() == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
|
||||
test(s+5, 5, s+10);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// move_iterator& operator+=(difference_type n);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
std::move_iterator<It>& rr = r += n;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
|
||||
test(s+5, 5, s+10);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// move_iterator operator-(difference_type n) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
const std::move_iterator<It> r(i);
|
||||
std::move_iterator<It> rr = r - n;
|
||||
assert(rr.base() == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
|
||||
test(s+5, 5, s);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// move_iterator& operator-=(difference_type n);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
std::move_iterator<It>& rr = r -= n;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
|
||||
test(s+5, 5, s);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <InputIterator Iter1, InputIterator Iter2>
|
||||
// requires HasEqualTo<Iter1, Iter2>
|
||||
// bool
|
||||
// operator==(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert((r1 == r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(input_iterator<char*>(s), input_iterator<char*>(s), true);
|
||||
test(input_iterator<char*>(s), input_iterator<char*>(s+1), false);
|
||||
test(forward_iterator<char*>(s), forward_iterator<char*>(s), true);
|
||||
test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), false);
|
||||
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), true);
|
||||
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), false);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
|
||||
test(s, s, true);
|
||||
test(s, s+1, false);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasLess<Iter2, Iter1>
|
||||
// bool
|
||||
// operator>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert((r1 > r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
|
||||
test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
|
||||
test(s, s, false);
|
||||
test(s, s+1, false);
|
||||
test(s+1, s, true);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasLess<Iter1, Iter2>
|
||||
// bool
|
||||
// operator>=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert((r1 >= r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
|
||||
test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
|
||||
test(s, s, true);
|
||||
test(s, s+1, false);
|
||||
test(s+1, s, true);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasLess<Iter1, Iter2>
|
||||
// bool
|
||||
// operator<(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert((r1 < r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
|
||||
test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
|
||||
test(s, s, false);
|
||||
test(s, s+1, true);
|
||||
test(s+1, s, false);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasLess<Iter2, Iter1>
|
||||
// bool
|
||||
// operator<=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert((r1 <= r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
|
||||
test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
|
||||
test(s, s, true);
|
||||
test(s, s+1, true);
|
||||
test(s+1, s, false);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <InputIterator Iter1, InputIterator Iter2>
|
||||
// requires HasEqualTo<Iter1, Iter2>
|
||||
// bool
|
||||
// operator!=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::move_iterator<It> r1(l);
|
||||
const std::move_iterator<It> r2(r);
|
||||
assert((r1 != r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(input_iterator<char*>(s), input_iterator<char*>(s), false);
|
||||
test(input_iterator<char*>(s), input_iterator<char*>(s+1), true);
|
||||
test(forward_iterator<char*>(s), forward_iterator<char*>(s), false);
|
||||
test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), true);
|
||||
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), false);
|
||||
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), true);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
|
||||
test(s, s, false);
|
||||
test(s, s+1, true);
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasConstructor<Iter, const U&>
|
||||
// move_iterator(const move_iterator<U> &u);
|
||||
|
||||
// test requires
|
||||
|
||||
#include <iterator>
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
std::move_iterator<U> r2(u);
|
||||
std::move_iterator<It> r1 = r2;
|
||||
}
|
||||
|
||||
struct base {};
|
||||
struct derived {};
|
||||
|
||||
int main()
|
||||
{
|
||||
derived d;
|
||||
|
||||
test<base*>(&d);
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasConstructor<Iter, const U&>
|
||||
// move_iterator(const move_iterator<U> &u);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
const std::move_iterator<U> r2(u);
|
||||
std::move_iterator<It> r1 = r2;
|
||||
assert(r1.base() == u);
|
||||
}
|
||||
|
||||
struct Base {};
|
||||
struct Derived : Base {};
|
||||
|
||||
int main()
|
||||
{
|
||||
Derived d;
|
||||
|
||||
test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
|
||||
test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
|
||||
test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
|
||||
test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
|
||||
test<Base*>(&d);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// move_iterator();
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::move_iterator<It> r;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<char*> >();
|
||||
test<forward_iterator<char*> >();
|
||||
test<bidirectional_iterator<char*> >();
|
||||
test<random_access_iterator<char*> >();
|
||||
test<char*>();
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// explicit move_iterator(Iter );
|
||||
|
||||
// test explicit
|
||||
|
||||
#include <iterator>
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
std::move_iterator<It> r = i;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(s);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// explicit move_iterator(Iter i);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
assert(r.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(input_iterator<char*>(s));
|
||||
test(forward_iterator<char*>(s));
|
||||
test(bidirectional_iterator<char*>(s));
|
||||
test(random_access_iterator<char*>(s));
|
||||
test(s);
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// move_iterator operator--(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
std::move_iterator<It> rr = r--;
|
||||
assert(r.base() == x);
|
||||
assert(rr.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
|
||||
test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
|
||||
test(s+1, s);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// move_iterator& operator--();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
std::move_iterator<It>& rr = --r;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
|
||||
test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
|
||||
test(s+1, s);
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// move_iterator operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
std::move_iterator<It> rr = r++;
|
||||
assert(r.base() == x);
|
||||
assert(rr.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(input_iterator<char*>(s), input_iterator<char*>(s+1));
|
||||
test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
|
||||
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
|
||||
test(s, s+1);
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// move_iterator& operator++();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
std::move_iterator<It>& rr = ++r;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(input_iterator<char*>(s), input_iterator<char*>(s+1));
|
||||
test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
|
||||
test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
|
||||
test(s, s+1);
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// unspecified operator[](difference_type n) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n,
|
||||
typename std::iterator_traits<It>::value_type x)
|
||||
{
|
||||
typedef typename std::iterator_traits<It>::value_type value_type;
|
||||
const std::move_iterator<It> r(i);
|
||||
value_type rr = r[n];
|
||||
assert(rr == x);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
struct do_nothing
|
||||
{
|
||||
void operator()(void*) const {}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "1234567890";
|
||||
test(random_access_iterator<char*>(s+5), 4, '0');
|
||||
test(s+5, 4, '0');
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
int i[5];
|
||||
typedef std::unique_ptr<int, do_nothing> Ptr;
|
||||
Ptr p[5];
|
||||
for (unsigned j = 0; j < 5; ++j)
|
||||
p[j].reset(i+j);
|
||||
test(p, 3, Ptr(i+3));
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// pointer operator->() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
assert(r.operator->() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[] = "123";
|
||||
test(s);
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// reference operator*() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
class A
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
A() : data_(1) {}
|
||||
~A() {data_ = -1;}
|
||||
|
||||
friend bool operator==(const A& x, const A& y)
|
||||
{return x.data_ == y.data_;}
|
||||
};
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::value_type x)
|
||||
{
|
||||
std::move_iterator<It> r(i);
|
||||
assert(*r == x);
|
||||
typename std::iterator_traits<It>::value_type x2 = *r;
|
||||
assert(x2 == x);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
struct do_nothing
|
||||
{
|
||||
void operator()(void*) const {}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
test(&a, A());
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
int i;
|
||||
std::unique_ptr<int, do_nothing> p(&i);
|
||||
test(&p, std::unique_ptr<int, do_nothing>(&i));
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasAssign<Iter, const U&>
|
||||
// move_iterator&
|
||||
// operator=(const move_iterator<U>& u);
|
||||
|
||||
// test requires
|
||||
|
||||
#include <iterator>
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
const std::move_iterator<U> r2(u);
|
||||
std::move_iterator<It> r1;
|
||||
r1 = r2;
|
||||
}
|
||||
|
||||
struct base {};
|
||||
struct derived {};
|
||||
|
||||
int main()
|
||||
{
|
||||
derived d;
|
||||
test<base*>(&d);
|
||||
}
|
@@ -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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasAssign<Iter, const U&>
|
||||
// move_iterator&
|
||||
// operator=(const move_iterator<U>& u);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
const std::move_iterator<U> r2(u);
|
||||
std::move_iterator<It> r1;
|
||||
std::move_iterator<It>& rr = r1 = r2;
|
||||
assert(r1.base() == u);
|
||||
assert(&rr == &r1);
|
||||
}
|
||||
|
||||
struct Base {};
|
||||
struct Derived : Base {};
|
||||
|
||||
int main()
|
||||
{
|
||||
Derived d;
|
||||
|
||||
test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
|
||||
test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
|
||||
test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
|
||||
test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
|
||||
test<Base*>(&d);
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// move_iterator
|
||||
|
||||
// Test nested types:
|
||||
|
||||
// template <InputIterator Iter>
|
||||
// class move_iterator {
|
||||
// public:
|
||||
// typedef Iter iterator_type;
|
||||
// typedef Iter::difference_type difference_type;
|
||||
// typedef Iterator pointer;
|
||||
// typedef Iter::value_type value_type;
|
||||
// typedef value_type&& reference;
|
||||
// };
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::move_iterator<It> R;
|
||||
typedef std::iterator_traits<It> T;
|
||||
static_assert((std::is_same<typename R::iterator_type, It>::value), "");
|
||||
static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
|
||||
static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
|
||||
static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
|
||||
#else
|
||||
static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
|
||||
#endif
|
||||
static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<input_iterator<char*> >();
|
||||
test<forward_iterator<char*> >();
|
||||
test<bidirectional_iterator<char*> >();
|
||||
test<random_access_iterator<char*> >();
|
||||
test<char*>();
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
12
test/std/iterators/predef.iterators/nothing_to_do.pass.cpp
Normal file
12
test/std/iterators/predef.iterators/nothing_to_do.pass.cpp
Normal 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()
|
||||
{
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// reverse_iterator();
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::reverse_iterator<It> r;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<bidirectional_iterator<const char*> >();
|
||||
test<random_access_iterator<char*> >();
|
||||
test<char*>();
|
||||
test<const char*>();
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// explicit reverse_iterator(Iter x);
|
||||
|
||||
// test explicit
|
||||
|
||||
#include <iterator>
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
std::reverse_iterator<It> r = i;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char s[] = "123";
|
||||
test(s);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// explicit reverse_iterator(Iter x);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
assert(r.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char s[] = "123";
|
||||
test(bidirectional_iterator<const char*>(s));
|
||||
test(random_access_iterator<const char*>(s));
|
||||
test(s);
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasConstructor<Iter, const U&>
|
||||
// reverse_iterator(const reverse_iterator<U> &u);
|
||||
|
||||
// test requires
|
||||
|
||||
#include <iterator>
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
std::reverse_iterator<U> r2(u);
|
||||
std::reverse_iterator<It> r1 = r2;
|
||||
}
|
||||
|
||||
struct base {};
|
||||
struct derived {};
|
||||
|
||||
int main()
|
||||
{
|
||||
derived d;
|
||||
|
||||
test<base*>(&d);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasConstructor<Iter, const U&>
|
||||
// reverse_iterator(const reverse_iterator<U> &u);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
const std::reverse_iterator<U> r2(u);
|
||||
std::reverse_iterator<It> r1 = r2;
|
||||
assert(r1.base() == u);
|
||||
}
|
||||
|
||||
struct Base {};
|
||||
struct Derived : Base {};
|
||||
|
||||
int main()
|
||||
{
|
||||
Derived d;
|
||||
|
||||
test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
|
||||
test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
|
||||
test<Base*>(&d);
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <class Iterator> reverse_iterator<Iterator>
|
||||
// make_reverse_iterator(Iterator i);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i)
|
||||
{
|
||||
const std::reverse_iterator<It> r = std::make_reverse_iterator(i);
|
||||
assert(r.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
random_access_iterator<const char*>b(s);
|
||||
random_access_iterator<const char*>e(s+10);
|
||||
while ( b != e )
|
||||
test ( b++ );
|
||||
}
|
||||
#else
|
||||
int main () {}
|
||||
#endif
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
|
||||
// requires HasEqualTo<Iter1, Iter2>
|
||||
// bool
|
||||
// operator!=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::reverse_iterator<It> r1(l);
|
||||
const std::reverse_iterator<It> r2(r);
|
||||
assert((r1 != r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), false);
|
||||
test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), true);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
|
||||
test(s, s, false);
|
||||
test(s, s+1, true);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// reverse_iterator operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It> rr = r++;
|
||||
assert(r.base() == x);
|
||||
assert(rr.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "123";
|
||||
test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
|
||||
test(s+1, s);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// reverse_iterator& operator++();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It>& rr = ++r;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "123";
|
||||
test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
|
||||
test(s+1, s);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// reverse_iterator operator+(difference_type n) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
const std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It> rr = r + n;
|
||||
assert(rr.base() == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
|
||||
test(s+5, 5, s);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// reverse_iterator& operator+=(difference_type n);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It>& rr = r += n;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
|
||||
test(s+5, 5, s);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// reverse_iterator operator--(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It> rr = r--;
|
||||
assert(r.base() == x);
|
||||
assert(rr.base() == i);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "123";
|
||||
test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
|
||||
test(s+1, s+2);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// reverse_iterator& operator--();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, It x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It>& rr = --r;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "123";
|
||||
test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
|
||||
test(s+1, s+2);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// reverse_iterator operator-(difference_type n) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
const std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It> rr = r - n;
|
||||
assert(rr.base() == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
|
||||
test(s+5, 5, s+10);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// reverse_iterator& operator-=(difference_type n);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It>& rr = r -= n;
|
||||
assert(r.base() == x);
|
||||
assert(&rr == &r);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
|
||||
test(s+5, 5, s+10);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// reference operator*() const;
|
||||
|
||||
// Be sure to respect LWG 198:
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
|
||||
// LWG 198 was superseded by LWG 2360
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
class A
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
A() : data_(1) {}
|
||||
~A() {data_ = -1;}
|
||||
|
||||
friend bool operator==(const A& x, const A& y)
|
||||
{return x.data_ == y.data_;}
|
||||
};
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::value_type x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
assert(*r == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
test(&a+1, A());
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasAssign<Iter, const U&>
|
||||
// reverse_iterator&
|
||||
// operator=(const reverse_iterator<U>& u);
|
||||
|
||||
// test requires
|
||||
|
||||
#include <iterator>
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
const std::reverse_iterator<U> r2(u);
|
||||
std::reverse_iterator<It> r1;
|
||||
r1 = r2;
|
||||
}
|
||||
|
||||
struct base {};
|
||||
struct derived {};
|
||||
|
||||
int main()
|
||||
{
|
||||
derived d;
|
||||
test<base*>(&d);
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <class U>
|
||||
// requires HasAssign<Iter, const U&>
|
||||
// reverse_iterator&
|
||||
// operator=(const reverse_iterator<U>& u);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It, class U>
|
||||
void
|
||||
test(U u)
|
||||
{
|
||||
const std::reverse_iterator<U> r2(u);
|
||||
std::reverse_iterator<It> r1;
|
||||
std::reverse_iterator<It>& rr = r1 = r2;
|
||||
assert(r1.base() == u);
|
||||
assert(&rr == &r1);
|
||||
}
|
||||
|
||||
struct Base {};
|
||||
struct Derived : Base {};
|
||||
|
||||
int main()
|
||||
{
|
||||
Derived d;
|
||||
|
||||
test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
|
||||
test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
|
||||
test<Base*>(&d);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
|
||||
// requires HasEqualTo<Iter1, Iter2>
|
||||
// bool
|
||||
// operator==(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::reverse_iterator<It> r1(l);
|
||||
const std::reverse_iterator<It> r2(r);
|
||||
assert((r1 == r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), true);
|
||||
test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), false);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
|
||||
test(s, s, true);
|
||||
test(s, s+1, false);
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasMinus<Iter2, Iter1>
|
||||
// auto operator-(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y)
|
||||
// -> decltype(y.base() - x.base());
|
||||
|
||||
#include <iterator>
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It1, class It2>
|
||||
void
|
||||
test(It1 l, It2 r, std::ptrdiff_t x)
|
||||
{
|
||||
const std::reverse_iterator<It1> r1(l);
|
||||
const std::reverse_iterator<It2> r2(r);
|
||||
assert((r1 - r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char s[3] = {0};
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<char*>(s), 0);
|
||||
test(random_access_iterator<char*>(s), random_access_iterator<const char*>(s+1), 1);
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<char*>(s), -1);
|
||||
test(s, s, 0);
|
||||
test(s, s+1, 1);
|
||||
test(s+1, s, -1);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasGreater<Iter1, Iter2>
|
||||
// bool
|
||||
// operator>(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::reverse_iterator<It> r1(l);
|
||||
const std::reverse_iterator<It> r2(r);
|
||||
assert((r1 > r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
|
||||
test(s, s, false);
|
||||
test(s, s+1, true);
|
||||
test(s+1, s, false);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasGreater<Iter1, Iter2>
|
||||
// bool
|
||||
// operator>=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::reverse_iterator<It> r1(l);
|
||||
const std::reverse_iterator<It> r2(r);
|
||||
assert((r1 >= r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
|
||||
test(s, s, true);
|
||||
test(s, s+1, true);
|
||||
test(s+1, s, false);
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// requires RandomAccessIterator<Iter>
|
||||
// unspecified operator[](difference_type n) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n,
|
||||
typename std::iterator_traits<It>::value_type x)
|
||||
{
|
||||
typedef typename std::iterator_traits<It>::value_type value_type;
|
||||
const std::reverse_iterator<It> r(i);
|
||||
value_type rr = r[n];
|
||||
assert(rr == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 4, '1');
|
||||
test(s+5, 4, '1');
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasGreater<Iter1, Iter2>
|
||||
// bool
|
||||
// operator<(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::reverse_iterator<It> r1(l);
|
||||
const std::reverse_iterator<It> r2(r);
|
||||
assert((r1 < r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
|
||||
test(s, s, false);
|
||||
test(s, s+1, false);
|
||||
test(s+1, s, true);
|
||||
}
|
@@ -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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
|
||||
// requires HasGreater<Iter1, Iter2>
|
||||
// bool
|
||||
// operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It l, It r, bool x)
|
||||
{
|
||||
const std::reverse_iterator<It> r1(l);
|
||||
const std::reverse_iterator<It> r2(r);
|
||||
assert((r1 <= r2) == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
|
||||
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
|
||||
test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
|
||||
test(s, s, true);
|
||||
test(s, s+1, false);
|
||||
test(s+1, s, true);
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// pointer operator->() const;
|
||||
|
||||
// Be sure to respect LWG 198:
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
|
||||
// LWG 198 was superseded by LWG 2360
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
|
||||
|
||||
|
||||
#include <iterator>
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
|
||||
class A
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
A() : data_(1) {}
|
||||
~A() {data_ = -1;}
|
||||
|
||||
int get() const {return data_;}
|
||||
|
||||
friend bool operator==(const A& x, const A& y)
|
||||
{return x.data_ == y.data_;}
|
||||
};
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::value_type x)
|
||||
{
|
||||
std::reverse_iterator<It> r(i);
|
||||
assert(r->get() == x.get());
|
||||
}
|
||||
|
||||
class B
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
B(int d=1) : data_(d) {}
|
||||
~B() {data_ = -1;}
|
||||
|
||||
int get() const {return data_;}
|
||||
|
||||
friend bool operator==(const B& x, const B& y)
|
||||
{return x.data_ == y.data_;}
|
||||
const B *operator&() const { return nullptr; }
|
||||
B *operator&() { return nullptr; }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
test(&a+1, A());
|
||||
|
||||
{
|
||||
std::list<B> l;
|
||||
l.push_back(B(0));
|
||||
l.push_back(B(1));
|
||||
l.push_back(B(2));
|
||||
|
||||
{
|
||||
std::list<B>::const_iterator i = l.begin();
|
||||
assert ( i->get() == 0 ); ++i;
|
||||
assert ( i->get() == 1 ); ++i;
|
||||
assert ( i->get() == 2 ); ++i;
|
||||
assert ( i == l.end ());
|
||||
}
|
||||
|
||||
{
|
||||
std::list<B>::const_reverse_iterator ri = l.rbegin();
|
||||
assert ( ri->get() == 2 ); ++ri;
|
||||
assert ( ri->get() == 1 ); ++ri;
|
||||
assert ( ri->get() == 0 ); ++ri;
|
||||
assert ( ri == l.rend ());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// template <RandomAccessIterator Iterator>
|
||||
// reverse_iterator<Iter>
|
||||
// operator+(Iter::difference_type n, const reverse_iterator<Iter>& x);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test(It i, typename std::iterator_traits<It>::difference_type n, It x)
|
||||
{
|
||||
const std::reverse_iterator<It> r(i);
|
||||
std::reverse_iterator<It> rr = n + r;
|
||||
assert(rr.base() == x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* s = "1234567890";
|
||||
test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
|
||||
test(s+5, 5, s);
|
||||
}
|
@@ -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()
|
||||
{
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// reverse_iterator
|
||||
|
||||
// Test nested types and data member:
|
||||
|
||||
// template <BidirectionalIterator Iter>
|
||||
// class reverse_iterator {
|
||||
// protected:
|
||||
// Iter current;
|
||||
// public:
|
||||
// iterator<typename iterator_traits<Iterator>::iterator_category,
|
||||
// typename iterator_traits<Iterator>::value_type,
|
||||
// typename iterator_traits<Iterator>::difference_type,
|
||||
// typename iterator_traits<Iterator>::pointer,
|
||||
// typename iterator_traits<Iterator>::reference> {
|
||||
// };
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class It>
|
||||
struct find_current
|
||||
: private std::reverse_iterator<It>
|
||||
{
|
||||
void test() {++(this->current);}
|
||||
};
|
||||
|
||||
template <class It>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::reverse_iterator<It> R;
|
||||
typedef std::iterator_traits<It> T;
|
||||
find_current<It> q;
|
||||
q.test();
|
||||
static_assert((std::is_same<typename R::iterator_type, It>::value), "");
|
||||
static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
|
||||
static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
|
||||
static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
|
||||
static_assert((std::is_same<typename R::pointer, typename std::iterator_traits<It>::pointer>::value), "");
|
||||
static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<bidirectional_iterator<char*> >();
|
||||
test<random_access_iterator<char*> >();
|
||||
test<char*>();
|
||||
}
|
Reference in New Issue
Block a user