libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator(const istream_iterator& x);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream_iterator<int> io;
|
||||
std::istream_iterator<int> i = io;
|
||||
assert(i == std::istream_iterator<int>());
|
||||
}
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> io(inf);
|
||||
std::istream_iterator<int> i = io;
|
||||
assert(i != std::istream_iterator<int>());
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istream_iterator<int> i;
|
||||
assert(i == std::istream_iterator<int>());
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator(istream_type& s);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
assert(i != std::istream_iterator<int>());
|
||||
assert(inf.peek() == ' ');
|
||||
assert(inf.good());
|
||||
int j = 0;
|
||||
inf >> j;
|
||||
assert(j == 23);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// const T* operator->() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
struct A
|
||||
{
|
||||
double d_;
|
||||
int i_;
|
||||
};
|
||||
|
||||
std::istream& operator>>(std::istream& is, A& a)
|
||||
{
|
||||
return is >> a.d_ >> a.i_;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf("1.5 23 ");
|
||||
std::istream_iterator<A> i(inf);
|
||||
assert(i->d_ == 1.5);
|
||||
assert(i->i_ == 23);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// const T& operator*() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 1);
|
||||
j = *i;
|
||||
assert(j == 1);
|
||||
++i;
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// template <class T, class charT, class traits, class Distance>
|
||||
// bool operator==(const istream_iterator<T,charT,traits,Distance> &x,
|
||||
// const istream_iterator<T,charT,traits,Distance> &y);
|
||||
//
|
||||
// template <class T, class charT, class traits, class Distance>
|
||||
// bool operator!=(const istream_iterator<T,charT,traits,Distance> &x,
|
||||
// const istream_iterator<T,charT,traits,Distance> &y);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf1(" 1 23");
|
||||
std::istringstream inf2(" 1 23");
|
||||
std::istream_iterator<int> i1(inf1);
|
||||
std::istream_iterator<int> i2(inf1);
|
||||
std::istream_iterator<int> i3(inf2);
|
||||
std::istream_iterator<int> i4;
|
||||
std::istream_iterator<int> i5;
|
||||
assert(i1 == i1);
|
||||
assert(i1 == i2);
|
||||
assert(i1 != i3);
|
||||
assert(i1 != i4);
|
||||
assert(i1 != i5);
|
||||
|
||||
assert(i2 == i2);
|
||||
assert(i2 != i3);
|
||||
assert(i2 != i4);
|
||||
assert(i2 != i5);
|
||||
|
||||
assert(i3 == i3);
|
||||
assert(i3 != i4);
|
||||
assert(i3 != i5);
|
||||
|
||||
assert(i4 == i4);
|
||||
assert(i4 == i5);
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
std::istream_iterator<int> icopy = i++;
|
||||
assert(icopy == i);
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
j = 0;
|
||||
j = *icopy;
|
||||
assert(j == 1);
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator& operator++();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
std::istream_iterator<int>& iref = ++i;
|
||||
assert(&iref == &i);
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class T, class charT = char, class traits = char_traits<charT>,
|
||||
// class Distance = ptrdiff_t>
|
||||
// class istream_iterator
|
||||
// : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef basic_istream<charT,traits> istream_type;
|
||||
// ...
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::istream_iterator<double> I1;
|
||||
static_assert((std::is_convertible<I1,
|
||||
std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
|
||||
const double*, const double&> >::value), "");
|
||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
|
||||
typedef std::istream_iterator<unsigned, wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
|
||||
const unsigned*, const unsigned&> >::value), "");
|
||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||
static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// istreambuf_iterator() throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istreambuf_iterator<char> i;
|
||||
assert(i == std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::istreambuf_iterator<wchar_t> i;
|
||||
assert(i == std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// istreambuf_iterator(basic_istream<charT,traits>& s) throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf;
|
||||
std::istreambuf_iterator<char> i(inf);
|
||||
assert(i == std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::istringstream inf("a");
|
||||
std::istreambuf_iterator<char> i(inf);
|
||||
assert(i != std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::wistringstream inf;
|
||||
std::istreambuf_iterator<wchar_t> i(inf);
|
||||
assert(i == std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"a");
|
||||
std::istreambuf_iterator<wchar_t> i(inf);
|
||||
assert(i != std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// istreambuf_iterator(const proxy& p) throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf("abc");
|
||||
std::istreambuf_iterator<char> j(inf);
|
||||
std::istreambuf_iterator<char> i = j++;
|
||||
assert(i != std::istreambuf_iterator<char>());
|
||||
assert(*i == 'b');
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"abc");
|
||||
std::istreambuf_iterator<wchar_t> j(inf);
|
||||
std::istreambuf_iterator<wchar_t> i = j++;
|
||||
assert(i != std::istreambuf_iterator<wchar_t>());
|
||||
assert(*i == L'b');
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// istreambuf_iterator(basic_streambuf<charT,traits>* s) throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istreambuf_iterator<char> i(nullptr);
|
||||
assert(i == std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::istringstream inf;
|
||||
std::istreambuf_iterator<char> i(inf.rdbuf());
|
||||
assert(i == std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::istringstream inf("a");
|
||||
std::istreambuf_iterator<char> i(inf.rdbuf());
|
||||
assert(i != std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::istreambuf_iterator<wchar_t> i(nullptr);
|
||||
assert(i == std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
{
|
||||
std::wistringstream inf;
|
||||
std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
|
||||
assert(i == std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"a");
|
||||
std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
|
||||
assert(i != std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// bool equal(istreambuf_iterator<charT,traits>& b) const;
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf1("abc");
|
||||
std::istringstream inf2("def");
|
||||
std::istreambuf_iterator<char> i1(inf1);
|
||||
std::istreambuf_iterator<char> i2(inf2);
|
||||
std::istreambuf_iterator<char> i3;
|
||||
std::istreambuf_iterator<char> i4;
|
||||
|
||||
assert( i1.equal(i1));
|
||||
assert( i1.equal(i2));
|
||||
assert(!i1.equal(i3));
|
||||
assert(!i1.equal(i4));
|
||||
|
||||
assert( i2.equal(i1));
|
||||
assert( i2.equal(i2));
|
||||
assert(!i2.equal(i3));
|
||||
assert(!i2.equal(i4));
|
||||
|
||||
assert(!i3.equal(i1));
|
||||
assert(!i3.equal(i2));
|
||||
assert( i3.equal(i3));
|
||||
assert( i3.equal(i4));
|
||||
|
||||
assert(!i4.equal(i1));
|
||||
assert(!i4.equal(i2));
|
||||
assert( i4.equal(i3));
|
||||
assert( i4.equal(i4));
|
||||
}
|
||||
{
|
||||
std::wistringstream inf1(L"abc");
|
||||
std::wistringstream inf2(L"def");
|
||||
std::istreambuf_iterator<wchar_t> i1(inf1);
|
||||
std::istreambuf_iterator<wchar_t> i2(inf2);
|
||||
std::istreambuf_iterator<wchar_t> i3;
|
||||
std::istreambuf_iterator<wchar_t> i4;
|
||||
|
||||
assert( i1.equal(i1));
|
||||
assert( i1.equal(i2));
|
||||
assert(!i1.equal(i3));
|
||||
assert(!i1.equal(i4));
|
||||
|
||||
assert( i2.equal(i1));
|
||||
assert( i2.equal(i2));
|
||||
assert(!i2.equal(i3));
|
||||
assert(!i2.equal(i4));
|
||||
|
||||
assert(!i3.equal(i1));
|
||||
assert(!i3.equal(i2));
|
||||
assert( i3.equal(i3));
|
||||
assert( i3.equal(i4));
|
||||
|
||||
assert(!i4.equal(i1));
|
||||
assert(!i4.equal(i2));
|
||||
assert( i4.equal(i3));
|
||||
assert( i4.equal(i4));
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// template <class charT, class traits>
|
||||
// bool operator!=(const istreambuf_iterator<charT,traits>& a,
|
||||
// const istreambuf_iterator<charT,traits>& b);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf1("abc");
|
||||
std::istringstream inf2("def");
|
||||
std::istreambuf_iterator<char> i1(inf1);
|
||||
std::istreambuf_iterator<char> i2(inf2);
|
||||
std::istreambuf_iterator<char> i3;
|
||||
std::istreambuf_iterator<char> i4;
|
||||
|
||||
assert(!(i1 != i1));
|
||||
assert(!(i1 != i2));
|
||||
assert( (i1 != i3));
|
||||
assert( (i1 != i4));
|
||||
|
||||
assert(!(i2 != i1));
|
||||
assert(!(i2 != i2));
|
||||
assert( (i2 != i3));
|
||||
assert( (i2 != i4));
|
||||
|
||||
assert( (i3 != i1));
|
||||
assert( (i3 != i2));
|
||||
assert(!(i3 != i3));
|
||||
assert(!(i3 != i4));
|
||||
|
||||
assert( (i4 != i1));
|
||||
assert( (i4 != i2));
|
||||
assert(!(i4 != i3));
|
||||
assert(!(i4 != i4));
|
||||
}
|
||||
{
|
||||
std::wistringstream inf1(L"abc");
|
||||
std::wistringstream inf2(L"def");
|
||||
std::istreambuf_iterator<wchar_t> i1(inf1);
|
||||
std::istreambuf_iterator<wchar_t> i2(inf2);
|
||||
std::istreambuf_iterator<wchar_t> i3;
|
||||
std::istreambuf_iterator<wchar_t> i4;
|
||||
|
||||
assert(!(i1 != i1));
|
||||
assert(!(i1 != i2));
|
||||
assert( (i1 != i3));
|
||||
assert( (i1 != i4));
|
||||
|
||||
assert(!(i2 != i1));
|
||||
assert(!(i2 != i2));
|
||||
assert( (i2 != i3));
|
||||
assert( (i2 != i4));
|
||||
|
||||
assert( (i3 != i1));
|
||||
assert( (i3 != i2));
|
||||
assert(!(i3 != i3));
|
||||
assert(!(i3 != i4));
|
||||
|
||||
assert( (i4 != i1));
|
||||
assert( (i4 != i2));
|
||||
assert(!(i4 != i3));
|
||||
assert(!(i4 != i4));
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// charT operator*() const
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf("abc");
|
||||
std::istreambuf_iterator<char> i(inf);
|
||||
assert(*i == 'a');
|
||||
++i;
|
||||
assert(*i == 'b');
|
||||
++i;
|
||||
assert(*i == 'c');
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"abc");
|
||||
std::istreambuf_iterator<wchar_t> i(inf);
|
||||
assert(*i == L'a');
|
||||
++i;
|
||||
assert(*i == L'b');
|
||||
++i;
|
||||
assert(*i == L'c');
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// template <class charT, class traits>
|
||||
// bool operator==(const istreambuf_iterator<charT,traits>& a,
|
||||
// const istreambuf_iterator<charT,traits>& b);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf1("abc");
|
||||
std::istringstream inf2("def");
|
||||
std::istreambuf_iterator<char> i1(inf1);
|
||||
std::istreambuf_iterator<char> i2(inf2);
|
||||
std::istreambuf_iterator<char> i3;
|
||||
std::istreambuf_iterator<char> i4;
|
||||
|
||||
assert( (i1 == i1));
|
||||
assert( (i1 == i2));
|
||||
assert(!(i1 == i3));
|
||||
assert(!(i1 == i4));
|
||||
|
||||
assert( (i2 == i1));
|
||||
assert( (i2 == i2));
|
||||
assert(!(i2 == i3));
|
||||
assert(!(i2 == i4));
|
||||
|
||||
assert(!(i3 == i1));
|
||||
assert(!(i3 == i2));
|
||||
assert( (i3 == i3));
|
||||
assert( (i3 == i4));
|
||||
|
||||
assert(!(i4 == i1));
|
||||
assert(!(i4 == i2));
|
||||
assert( (i4 == i3));
|
||||
assert( (i4 == i4));
|
||||
}
|
||||
{
|
||||
std::wistringstream inf1(L"abc");
|
||||
std::wistringstream inf2(L"def");
|
||||
std::istreambuf_iterator<wchar_t> i1(inf1);
|
||||
std::istreambuf_iterator<wchar_t> i2(inf2);
|
||||
std::istreambuf_iterator<wchar_t> i3;
|
||||
std::istreambuf_iterator<wchar_t> i4;
|
||||
|
||||
assert( (i1 == i1));
|
||||
assert( (i1 == i2));
|
||||
assert(!(i1 == i3));
|
||||
assert(!(i1 == i4));
|
||||
|
||||
assert( (i2 == i1));
|
||||
assert( (i2 == i2));
|
||||
assert(!(i2 == i3));
|
||||
assert(!(i2 == i4));
|
||||
|
||||
assert(!(i3 == i1));
|
||||
assert(!(i3 == i2));
|
||||
assert( (i3 == i3));
|
||||
assert( (i3 == i4));
|
||||
|
||||
assert(!(i4 == i1));
|
||||
assert(!(i4 == i2));
|
||||
assert( (i4 == i3));
|
||||
assert( (i4 == i4));
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// pointer operator->() const;
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <streambuf>
|
||||
|
||||
typedef char C;
|
||||
int main ()
|
||||
{
|
||||
std::istringstream s("filename");
|
||||
std::istreambuf_iterator<char> i(s);
|
||||
|
||||
(*i).~C(); // This is well-formed...
|
||||
i->~C(); // ... so this should be supported!
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// proxy istreambuf_iterator<charT,traits>::operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf("abc");
|
||||
std::istreambuf_iterator<char> i(inf);
|
||||
assert(*i++ == 'a');
|
||||
assert(*i++ == 'b');
|
||||
assert(*i++ == 'c');
|
||||
assert(i == std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"abc");
|
||||
std::istreambuf_iterator<wchar_t> i(inf);
|
||||
assert(*i++ == L'a');
|
||||
assert(*i++ == L'b');
|
||||
assert(*i++ == L'c');
|
||||
assert(i == std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
// istreambuf_iterator<charT,traits>&
|
||||
// istreambuf_iterator<charT,traits>::operator++();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf("abc");
|
||||
std::istreambuf_iterator<char> i(inf);
|
||||
assert(*i == 'a');
|
||||
assert(*++i == 'b');
|
||||
assert(*++i == 'c');
|
||||
assert(++i == std::istreambuf_iterator<char>());
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"abc");
|
||||
std::istreambuf_iterator<wchar_t> i(inf);
|
||||
assert(*i == L'a');
|
||||
assert(*++i == L'b');
|
||||
assert(*++i == L'c');
|
||||
assert(++i == std::istreambuf_iterator<wchar_t>());
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template<class charT, class traits = char_traits<charT> >
|
||||
// class istreambuf_iterator
|
||||
// : public iterator<input_iterator_tag, charT,
|
||||
// typename traits::off_type, charT*,
|
||||
// charT>
|
||||
// {
|
||||
// public:
|
||||
// ...
|
||||
// proxy operator++(int);
|
||||
|
||||
// class proxy
|
||||
// {
|
||||
// public:
|
||||
// charT operator*();
|
||||
// };
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream inf("abc");
|
||||
std::istreambuf_iterator<char> i(inf);
|
||||
assert(*i++ == 'a');
|
||||
}
|
||||
{
|
||||
std::wistringstream inf(L"abc");
|
||||
std::istreambuf_iterator<wchar_t> i(inf);
|
||||
assert(*i++ == L'a');
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template<class charT, class traits = char_traits<charT> >
|
||||
// class istreambuf_iterator
|
||||
// : public iterator<input_iterator_tag, charT,
|
||||
// typename traits::off_type, unspecified,
|
||||
// charT>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits::int_type int_type;
|
||||
// typedef basic_streambuf<charT,traits> streambuf_type;
|
||||
// typedef basic_istream<charT,traits> istream_type;
|
||||
// ...
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::istreambuf_iterator<char> I1;
|
||||
static_assert((std::is_convertible<I1,
|
||||
std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type,
|
||||
char*, char> >::value), "");
|
||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
|
||||
static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
|
||||
static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
|
||||
|
||||
typedef std::istreambuf_iterator<wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type,
|
||||
wchar_t*, wchar_t> >::value), "");
|
||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||
static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
|
||||
static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
|
||||
static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class T, size_t N> T* begin(T (&array)[N]);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {1, 2, 3};
|
||||
int* i = std::begin(ia);
|
||||
assert(*i == 1);
|
||||
*i = 2;
|
||||
assert(ia[0] == 2);
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class C> auto begin(const C& c) -> decltype(c.begin());
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {1, 2, 3};
|
||||
const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
|
||||
std::vector<int>::const_iterator i = begin(v);
|
||||
assert(*i == 1);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class C> auto begin(C& c) -> decltype(c.begin());
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {1, 2, 3};
|
||||
std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
|
||||
std::vector<int>::iterator i = begin(v);
|
||||
assert(*i == 1);
|
||||
*i = 2;
|
||||
assert(*i == 2);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class T, size_t N> T* end(T (&array)[N]);
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {1, 2, 3};
|
||||
int* i = std::begin(ia);
|
||||
int* e = std::end(ia);
|
||||
assert(e == ia + 3);
|
||||
assert(e - i == 3);
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class C> auto end(const C& c) -> decltype(c.end());
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {1, 2, 3};
|
||||
const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
|
||||
std::vector<int>::const_iterator i = end(v);
|
||||
assert(i == v.cend());
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class C> auto end(C& c) -> decltype(c.end());
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {1, 2, 3};
|
||||
std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
|
||||
std::vector<int>::iterator i = end(v);
|
||||
assert(i == v.end());
|
||||
}
|
12
test/iterators/stream.iterators/nothing_to_do.pass.cpp
Normal file
12
test/iterators/stream.iterators/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostream_iterator
|
||||
|
||||
// ostream_iterator(const ostream_iterator& x);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostream_iterator<int> i(outf);
|
||||
std::ostream_iterator<int> j = i;
|
||||
assert(outf.good());
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostream_iterator
|
||||
|
||||
// ostream_iterator(ostream_type& s);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostream_iterator<int> i(outf);
|
||||
assert(outf.good());
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostream_iterator
|
||||
|
||||
// ostream_iterator(ostream_type& s, const charT* delimiter);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostream_iterator<int> i(outf, ", ");
|
||||
assert(outf.good());
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostream_iterator<double, wchar_t> i(outf, L", ");
|
||||
assert(outf.good());
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostream_iterator
|
||||
|
||||
// ostream_iterator& operator=(const T& value);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostream_iterator<int> i(outf);
|
||||
i = 2.4;
|
||||
assert(outf.str() == "2");
|
||||
}
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostream_iterator<int> i(outf, ", ");
|
||||
i = 2.4;
|
||||
assert(outf.str() == "2, ");
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostream_iterator<int, wchar_t> i(outf);
|
||||
i = 2.4;
|
||||
assert(outf.str() == L"2");
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostream_iterator<int, wchar_t> i(outf, L", ");
|
||||
i = 2.4;
|
||||
assert(outf.str() == L"2, ");
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostream_iterator
|
||||
|
||||
// ostream_iterator& operator*() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream os;
|
||||
std::ostream_iterator<int> i(os);
|
||||
std::ostream_iterator<int>& iref = *i;
|
||||
assert(&iref == &i);
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostream_iterator
|
||||
|
||||
// ostream_iterator& operator++();
|
||||
// ostream_iterator& operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream os;
|
||||
std::ostream_iterator<int> i(os);
|
||||
std::ostream_iterator<int>& iref1 = ++i;
|
||||
assert(&iref1 == &i);
|
||||
std::ostream_iterator<int>& iref2 = i++;
|
||||
assert(&iref2 == &i);
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class T, class charT = char, class traits = char_traits<charT>,
|
||||
// class Distance = ptrdiff_t>
|
||||
// class ostream_iterator
|
||||
// : public iterator<output_iterator_tag, void, void, void, void>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef basic_istream<charT,traits> istream_type;
|
||||
// ...
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::ostream_iterator<double> I1;
|
||||
static_assert((std::is_convertible<I1,
|
||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
|
||||
typedef std::ostream_iterator<unsigned, wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||
static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostreambuf_iterator
|
||||
|
||||
// ostreambuf_iterator(ostream_type& s) throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostreambuf_iterator<char> i(outf);
|
||||
assert(!i.failed());
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostreambuf_iterator<wchar_t> i(outf);
|
||||
assert(!i.failed());
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostreambuf_iterator
|
||||
|
||||
// ostreambuf_iterator(streambuf_type* s) throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostreambuf_iterator<char> i(outf.rdbuf());
|
||||
assert(!i.failed());
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostreambuf_iterator<wchar_t> i(outf.rdbuf());
|
||||
assert(!i.failed());
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostreambuf_iterator
|
||||
|
||||
// ostreambuf_iterator<charT,traits>&
|
||||
// operator=(charT c);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostreambuf_iterator<char> i(outf);
|
||||
i = 'a';
|
||||
assert(outf.str() == "a");
|
||||
i = 'b';
|
||||
assert(outf.str() == "ab");
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostreambuf_iterator<wchar_t> i(outf);
|
||||
i = L'a';
|
||||
assert(outf.str() == L"a");
|
||||
i = L'b';
|
||||
assert(outf.str() == L"ab");
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostreambuf_iterator
|
||||
|
||||
// ostreambuf_iterator<charT,traits>& operator*();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostreambuf_iterator<char> i(outf);
|
||||
std::ostreambuf_iterator<char>& iref = *i;
|
||||
assert(&iref == &i);
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostreambuf_iterator<wchar_t> i(outf);
|
||||
std::ostreambuf_iterator<wchar_t>& iref = *i;
|
||||
assert(&iref == &i);
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostreambuf_iterator
|
||||
|
||||
// bool failed() const throw();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostreambuf_iterator<char> i(nullptr);
|
||||
assert(i.failed());
|
||||
}
|
||||
{
|
||||
std::ostreambuf_iterator<wchar_t> i(nullptr);
|
||||
assert(i.failed());
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class ostreambuf_iterator
|
||||
|
||||
// ostreambuf_iterator<charT,traits>& operator++();
|
||||
// ostreambuf_iterator<charT,traits>& operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream outf;
|
||||
std::ostreambuf_iterator<char> i(outf);
|
||||
std::ostreambuf_iterator<char>& iref = ++i;
|
||||
assert(&iref == &i);
|
||||
std::ostreambuf_iterator<char>& iref2 = i++;
|
||||
assert(&iref2 == &i);
|
||||
}
|
||||
{
|
||||
std::wostringstream outf;
|
||||
std::ostreambuf_iterator<wchar_t> i(outf);
|
||||
std::ostreambuf_iterator<wchar_t>& iref = ++i;
|
||||
assert(&iref == &i);
|
||||
std::ostreambuf_iterator<wchar_t>& iref2 = i++;
|
||||
assert(&iref2 == &i);
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class ostreambuf_iterator
|
||||
// : public iterator<output_iterator_tag, void, void, void, void>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef basic_streambuf<charT, traits> streambuf_type;
|
||||
// typedef basic_ostream<charT, traits> ostream_type;
|
||||
// ...
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::ostreambuf_iterator<char> I1;
|
||||
static_assert((std::is_convertible<I1,
|
||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
|
||||
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
|
||||
|
||||
typedef std::ostreambuf_iterator<wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||
static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
|
||||
static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
|
||||
}
|
Reference in New Issue
Block a user