mirror of git://gcc.gnu.org/git/gcc.git
re PR libstdc++/25482 (Specialize (overload) std::copy/find for streambuf iterators)
2006-03-21 Paolo Carlini <pcarlini@suse.de> PR libstdc++/25482 * include/bits/stl_algobase.h (__copy_aux(_CharT*, _CharT*, ostreambuf_iterator<_CharT>), __copy_aux(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT>), __copy_aux(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT*), copy(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, ostreambuf_iterator<_CharT>)): Declare. * include/bits/stl_algo.h (find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT)): Likewise. * include/bits/streambuf_iterator.h (copy(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, ostreambuf_iterator<_CharT>), __copy_aux(_CharT*, _CharT*, ostreambuf_iterator<_CharT>), __copy_aux(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT>), __copy_aux(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT*), find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT)): Define. (class istreambuf_iterator<>, class ostreambuf_iterator<>): Declare friends. * include/std/std_streambuf.h (class basic_streambuf<>): Likewise. * include/bits/cpp_type_traits.h (struct __is_char<>): Add. * testsuite/25_algorithms/copy/streambuf_iterators/char/1.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/char/2.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/char/3.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/1.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/2.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/3.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc: New. * testsuite/25_algorithms/find/istreambuf_iterators/char/1.cc: New. * testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc: New. * testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc: New. * testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc: New. * testsuite/performance/25_algorithms/copy_streambuf_iterators.cc: New. * testsuite/performance/25_algorithms/find_istreambuf_iterators.cc: New. From-SVN: r112247
This commit is contained in:
parent
69bdb292fd
commit
0002d5d2bc
|
|
@ -1,3 +1,39 @@
|
|||
2006-03-21 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/25482
|
||||
* include/bits/stl_algobase.h (__copy_aux(_CharT*, _CharT*,
|
||||
ostreambuf_iterator<_CharT>), __copy_aux(const _CharT*, const _CharT*,
|
||||
ostreambuf_iterator<_CharT>), __copy_aux(istreambuf_iterator<_CharT>,
|
||||
istreambuf_iterator<_CharT>, _CharT*), copy(istreambuf_iterator<_CharT>,
|
||||
istreambuf_iterator<_CharT>, ostreambuf_iterator<_CharT>)): Declare.
|
||||
* include/bits/stl_algo.h (find(istreambuf_iterator<_CharT>,
|
||||
istreambuf_iterator<_CharT>, _CharT)): Likewise.
|
||||
* include/bits/streambuf_iterator.h (copy(istreambuf_iterator<_CharT>,
|
||||
istreambuf_iterator<_CharT>, ostreambuf_iterator<_CharT>),
|
||||
__copy_aux(_CharT*, _CharT*, ostreambuf_iterator<_CharT>),
|
||||
__copy_aux(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT>),
|
||||
__copy_aux(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>,
|
||||
_CharT*), find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>,
|
||||
_CharT)): Define.
|
||||
(class istreambuf_iterator<>, class ostreambuf_iterator<>): Declare
|
||||
friends.
|
||||
* include/std/std_streambuf.h (class basic_streambuf<>): Likewise.
|
||||
* include/bits/cpp_type_traits.h (struct __is_char<>): Add.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/char/1.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/char/2.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/char/3.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/1.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/2.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/3.cc: New.
|
||||
* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc: New.
|
||||
* testsuite/25_algorithms/find/istreambuf_iterators/char/1.cc: New.
|
||||
* testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc: New.
|
||||
* testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc: New.
|
||||
* testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc: New.
|
||||
* testsuite/performance/25_algorithms/copy_streambuf_iterators.cc: New.
|
||||
* testsuite/performance/25_algorithms/find_istreambuf_iterators.cc: New.
|
||||
|
||||
006-03-13 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/postypes.h (fpos<>::operator==, operator!=): Remove,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// The -*- C++ -*- type traits classes for internal use in libstdc++
|
||||
|
||||
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
|
||||
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
|
|
@ -385,6 +385,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
};
|
||||
};
|
||||
|
||||
//
|
||||
// For use in std::copy and std::find overloads for streambuf iterators.
|
||||
//
|
||||
template<typename _Tp>
|
||||
struct __is_char
|
||||
{
|
||||
enum { __value = 0 };
|
||||
typedef __false_type __type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct __is_char<char>
|
||||
{
|
||||
enum { __value = 1 };
|
||||
typedef __true_type __type;
|
||||
};
|
||||
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
template<>
|
||||
struct __is_char<wchar_t>
|
||||
{
|
||||
enum { __value = 1 };
|
||||
typedef __true_type __type;
|
||||
};
|
||||
#endif
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
||||
#endif //_CPP_TYPE_TRAITS_H
|
||||
|
|
|
|||
|
|
@ -294,6 +294,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @if maint
|
||||
* This is an overload of find() for streambuf iterators.
|
||||
* @endif
|
||||
*/
|
||||
template<typename _CharT>
|
||||
typename __enable_if<istreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT);
|
||||
|
||||
/**
|
||||
* @brief Find the first occurrence of a value in a sequence.
|
||||
* @param first An input iterator.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Bits and pieces used in algorithms -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
|
@ -165,8 +166,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
iter_swap(__a, __b);
|
||||
}
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
/**
|
||||
* @brief This does what you think it does.
|
||||
|
|
@ -316,6 +317,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
return std::__copy<__simple, _Category>::copy(__first, __last, __result);
|
||||
}
|
||||
|
||||
// Helpers for streambuf iterators (either istream or ostream).
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
__copy_aux(_CharT*, _CharT*, ostreambuf_iterator<_CharT>);
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
__copy_aux(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT>);
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<_CharT*, __is_char<_CharT>::__value>::__type
|
||||
__copy_aux(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>,
|
||||
_CharT*);
|
||||
|
||||
template<bool, bool>
|
||||
struct __copy_normal
|
||||
{
|
||||
|
|
@ -385,7 +402,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
return std::__copy_normal<__in, __out>::__copy_n(__first, __last,
|
||||
__result);
|
||||
}
|
||||
|
||||
|
||||
// Overload for streambuf iterators.
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
copy(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>,
|
||||
ostreambuf_iterator<_CharT>);
|
||||
|
||||
template<bool, typename>
|
||||
struct __copy_backward
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Streambuf iterators
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
|
|
@ -41,9 +41,13 @@
|
|||
#include <streambuf>
|
||||
#include <debug/debug.h>
|
||||
|
||||
// NB: Should specialize copy, find algorithms for streambuf iterators.
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
copy(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>,
|
||||
ostreambuf_iterator<_CharT>);
|
||||
|
||||
// 24.5.3 Template class istreambuf_iterator
|
||||
/// Provides input iterator semantics for streambufs.
|
||||
|
|
@ -63,6 +67,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
typedef basic_istream<_CharT, _Traits> istream_type;
|
||||
//@}
|
||||
|
||||
template<typename _CharT2>
|
||||
friend typename __enable_if<ostreambuf_iterator<_CharT2>,
|
||||
__is_char<_CharT2>::__value>::__type
|
||||
copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
|
||||
ostreambuf_iterator<_CharT2>);
|
||||
|
||||
template<typename _CharT2>
|
||||
friend typename __enable_if<_CharT2*,
|
||||
__is_char<_CharT2>::__value>::__type
|
||||
__copy_aux(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
|
||||
_CharT2*);
|
||||
|
||||
template<typename _CharT2>
|
||||
friend typename __enable_if<istreambuf_iterator<_CharT2>,
|
||||
__is_char<_CharT2>::__value>::__type
|
||||
find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
|
||||
_CharT2);
|
||||
|
||||
private:
|
||||
// 24.5.3 istreambuf_iterator
|
||||
// p 1
|
||||
|
|
@ -201,6 +223,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
typedef basic_ostream<_CharT, _Traits> ostream_type;
|
||||
//@}
|
||||
|
||||
template<typename _CharT2>
|
||||
friend typename __enable_if<ostreambuf_iterator<_CharT2>,
|
||||
__is_char<_CharT2>::__value>::__type
|
||||
copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
|
||||
ostreambuf_iterator<_CharT2>);
|
||||
|
||||
private:
|
||||
streambuf_type* _M_sbuf;
|
||||
bool _M_failed;
|
||||
|
|
@ -255,6 +283,123 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
}
|
||||
};
|
||||
|
||||
// Overloads for streambuf iterators.
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
copy(istreambuf_iterator<_CharT> __first,
|
||||
istreambuf_iterator<_CharT> __last,
|
||||
ostreambuf_iterator<_CharT> __result)
|
||||
{
|
||||
if (__first._M_sbuf && !__last._M_sbuf && !__result._M_failed)
|
||||
{
|
||||
bool __ineof;
|
||||
__copy_streambufs_eof(__first._M_sbuf, __result._M_sbuf, __ineof);
|
||||
if (!__ineof)
|
||||
__result._M_failed = true;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
__copy_aux(_CharT* __first, _CharT* __last,
|
||||
ostreambuf_iterator<_CharT> __result)
|
||||
{
|
||||
const streamsize __num = __last - __first;
|
||||
if (__num > 0)
|
||||
__result._M_put(__first, __num);
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<ostreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
__copy_aux(const _CharT* __first, const _CharT* __last,
|
||||
ostreambuf_iterator<_CharT> __result)
|
||||
{
|
||||
const streamsize __num = __last - __first;
|
||||
if (__num > 0)
|
||||
__result._M_put(__first, __num);
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<_CharT*, __is_char<_CharT>::__value>::__type
|
||||
__copy_aux(istreambuf_iterator<_CharT> __first,
|
||||
istreambuf_iterator<_CharT> __last, _CharT* __result)
|
||||
{
|
||||
typedef istreambuf_iterator<_CharT> __is_iterator_type;
|
||||
typedef typename __is_iterator_type::traits_type traits_type;
|
||||
typedef typename __is_iterator_type::streambuf_type streambuf_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
|
||||
if (__first._M_sbuf && !__last._M_sbuf)
|
||||
{
|
||||
streambuf_type* __sb = __first._M_sbuf;
|
||||
int_type __c = __sb->sgetc();
|
||||
while (!traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
{
|
||||
const streamsize __n = __sb->egptr() - __sb->gptr();
|
||||
if (__n > 1)
|
||||
{
|
||||
traits_type::copy(__result, __sb->gptr(), __n);
|
||||
__sb->gbump(__n);
|
||||
__result += __n;
|
||||
__c = __sb->underflow();
|
||||
}
|
||||
else
|
||||
{
|
||||
*__result++ = traits_type::to_char_type(__c);
|
||||
__c = __sb->snextc();
|
||||
}
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<istreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
find(istreambuf_iterator<_CharT> __first,
|
||||
istreambuf_iterator<_CharT> __last, _CharT __val)
|
||||
{
|
||||
typedef istreambuf_iterator<_CharT> __is_iterator_type;
|
||||
typedef typename __is_iterator_type::traits_type traits_type;
|
||||
typedef typename __is_iterator_type::streambuf_type streambuf_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
|
||||
if (__first._M_sbuf && !__last._M_sbuf)
|
||||
{
|
||||
const int_type __ival = traits_type::to_int_type(__val);
|
||||
streambuf_type* __sb = __first._M_sbuf;
|
||||
int_type __c = __sb->sgetc();
|
||||
while (!traits_type::eq_int_type(__c, traits_type::eof())
|
||||
&& !traits_type::eq_int_type(__c, __ival))
|
||||
{
|
||||
streamsize __n = __sb->egptr() - __sb->gptr();
|
||||
if (__n > 1)
|
||||
{
|
||||
const _CharT* __p = traits_type::find(__sb->gptr(),
|
||||
__n, __val);
|
||||
if (__p)
|
||||
__n = __p - __sb->gptr();
|
||||
__sb->gbump(__n);
|
||||
__c = __sb->sgetc();
|
||||
}
|
||||
else
|
||||
__c = __sb->snextc();
|
||||
}
|
||||
|
||||
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
__first._M_c = __c;
|
||||
else
|
||||
__first._M_sbuf = 0;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include <iosfwd>
|
||||
#include <bits/localefwd.h>
|
||||
#include <bits/ios_base.h>
|
||||
#include <bits/cpp_type_traits.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
|
|
@ -55,10 +56,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
*/
|
||||
template<typename _CharT, typename _Traits>
|
||||
streamsize
|
||||
__copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin,
|
||||
basic_streambuf<_CharT, _Traits>* __sbout,
|
||||
bool& __ineof);
|
||||
|
||||
__copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
|
||||
basic_streambuf<_CharT, _Traits>*, bool&);
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<_CharT*, __is_char<_CharT>::__value>::__type
|
||||
__copy_aux(istreambuf_iterator<_CharT>,
|
||||
istreambuf_iterator<_CharT>, _CharT*);
|
||||
|
||||
template<typename _CharT>
|
||||
typename __enable_if<istreambuf_iterator<_CharT>,
|
||||
__is_char<_CharT>::__value>::__type
|
||||
find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT);
|
||||
|
||||
/**
|
||||
* @brief The actual work of input and output (interface).
|
||||
*
|
||||
|
|
@ -152,18 +162,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
friend class ostreambuf_iterator<char_type, traits_type>;
|
||||
|
||||
friend streamsize
|
||||
__copy_streambufs_eof<>(__streambuf_type* __sbin,
|
||||
__streambuf_type* __sbout, bool& __ineof);
|
||||
|
||||
__copy_streambufs_eof<>(__streambuf_type*, __streambuf_type*, bool&);
|
||||
|
||||
template<typename _CharT2>
|
||||
friend typename __enable_if<_CharT2*,
|
||||
__is_char<_CharT2>::__value>::__type
|
||||
__copy_aux(istreambuf_iterator<_CharT2>,
|
||||
istreambuf_iterator<_CharT2>, _CharT2*);
|
||||
|
||||
template<typename _CharT2>
|
||||
friend typename __enable_if<istreambuf_iterator<_CharT2>,
|
||||
__is_char<_CharT2>::__value>::__type
|
||||
find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
|
||||
_CharT2);
|
||||
|
||||
template<typename _CharT2, typename _Traits2>
|
||||
friend basic_istream<_CharT2, _Traits2>&
|
||||
operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
|
||||
|
||||
|
||||
template<typename _CharT2, typename _Traits2, typename _Alloc>
|
||||
friend basic_istream<_CharT2, _Traits2>&
|
||||
operator>>(basic_istream<_CharT2, _Traits2>&,
|
||||
basic_string<_CharT2, _Traits2, _Alloc>&);
|
||||
|
||||
|
||||
template<typename _CharT2, typename _Traits2, typename _Alloc>
|
||||
friend basic_istream<_CharT2, _Traits2>&
|
||||
getline(basic_istream<_CharT2, _Traits2>&,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
typedef ostreambuf_iterator<char> out_iterator_type;
|
||||
|
||||
const char data1[] = "Drei Phantasien nach Friedrich Holderlin";
|
||||
const string str1(data1);
|
||||
istringstream iss1(str1);
|
||||
in_iterator_type beg1(iss1);
|
||||
in_iterator_type end1;
|
||||
|
||||
ostringstream oss1;
|
||||
out_iterator_type out1(oss1);
|
||||
|
||||
out1 = copy(beg1, beg1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(end1, end1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = 'x';
|
||||
VERIFY( oss1.str() == str1 + 'x' );
|
||||
oss1.str("");
|
||||
|
||||
iss1.seekg(0);
|
||||
oss1.seekp(0);
|
||||
oss1.str("");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = 'y';
|
||||
VERIFY( oss1.str() == str1 + 'y' );
|
||||
oss1.str("");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == "" );
|
||||
|
||||
iss1.seekg(0);
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
|
||||
const char data1[] = "Drei Phantasien nach Friedrich Holderlin";
|
||||
const string str1(data1);
|
||||
istringstream iss1(str1);
|
||||
in_iterator_type beg1(iss1);
|
||||
in_iterator_type end1;
|
||||
|
||||
char buffer1[sizeof(data1) * 5];
|
||||
memset(buffer1, '*', sizeof(buffer1));
|
||||
char* out1 = buffer1;
|
||||
|
||||
out1 = copy(beg1, beg1, out1);
|
||||
VERIFY( out1 == buffer1 );
|
||||
|
||||
out1 = copy(end1, end1, out1);
|
||||
VERIFY( out1 == buffer1 );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( string(buffer1, out1) == str1 );
|
||||
*out1++ = 'x';
|
||||
VERIFY( string(buffer1, out1) == str1 + 'x' );
|
||||
memset(buffer1, '*', sizeof(buffer1));
|
||||
|
||||
iss1.seekg(0);
|
||||
out1 = buffer1;
|
||||
memset(buffer1, '*', sizeof(buffer1));
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( string(buffer1, out1) == str1 );
|
||||
*out1++ = 'y';
|
||||
VERIFY( string(buffer1, out1) == str1 + 'y' );
|
||||
out1 = buffer1;
|
||||
memset(buffer1, '*', sizeof(buffer1));
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( string(buffer1, out1) == "" );
|
||||
|
||||
iss1.seekg(0);
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( string(buffer1, out1) == str1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef ostreambuf_iterator<char> out_iterator_type;
|
||||
|
||||
const char data1[] = "Drei Phantasien nach Friedrich Holderlin";
|
||||
const string str1(data1);
|
||||
const char* beg1 = data1;
|
||||
const char* end1 = beg1 + str1.size();
|
||||
|
||||
ostringstream oss1;
|
||||
out_iterator_type out1(oss1);
|
||||
|
||||
out1 = copy(beg1, beg1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(end1, end1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = 'x';
|
||||
VERIFY( oss1.str() == str1 + 'x' );
|
||||
oss1.str("");
|
||||
|
||||
oss1.seekp(0);
|
||||
oss1.str("");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = 'y';
|
||||
VERIFY( oss1.str() == str1 + 'y' );
|
||||
oss1.str("");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 + str1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
|
||||
ifstream fbuf_ref("istream_unformatted-1.txt"),
|
||||
fbuf("istream_unformatted-1.txt");
|
||||
|
||||
char buffer_ref[16500],
|
||||
buffer[16500];
|
||||
|
||||
fbuf_ref.read(buffer_ref, 16500);
|
||||
|
||||
in_iterator_type beg(fbuf);
|
||||
in_iterator_type end;
|
||||
copy(beg, end, buffer);
|
||||
|
||||
VERIFY( fbuf_ref.good() );
|
||||
VERIFY( fbuf.good() );
|
||||
|
||||
VERIFY( !memcmp(buffer, buffer_ref, 16500) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<wchar_t> in_iterator_type;
|
||||
typedef ostreambuf_iterator<wchar_t> out_iterator_type;
|
||||
|
||||
const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin";
|
||||
const wstring str1(data1);
|
||||
wistringstream iss1(str1);
|
||||
in_iterator_type beg1(iss1);
|
||||
in_iterator_type end1;
|
||||
|
||||
wostringstream oss1;
|
||||
out_iterator_type out1(oss1);
|
||||
|
||||
out1 = copy(beg1, beg1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(end1, end1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = L'x';
|
||||
VERIFY( oss1.str() == str1 + L'x' );
|
||||
oss1.str(L"");
|
||||
|
||||
iss1.seekg(0);
|
||||
oss1.seekp(0);
|
||||
oss1.str(L"");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = L'y';
|
||||
VERIFY( oss1.str() == str1 + L'y' );
|
||||
oss1.str(L"");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == L"" );
|
||||
|
||||
iss1.seekg(0);
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<wchar_t> in_iterator_type;
|
||||
|
||||
const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin";
|
||||
const wstring str1(data1);
|
||||
wistringstream iss1(str1);
|
||||
in_iterator_type beg1(iss1);
|
||||
in_iterator_type end1;
|
||||
|
||||
wchar_t buffer1[sizeof(data1) * 5 / sizeof(wchar_t)];
|
||||
wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t));
|
||||
wchar_t* out1 = buffer1;
|
||||
|
||||
out1 = copy(beg1, beg1, out1);
|
||||
VERIFY( out1 == buffer1 );
|
||||
|
||||
out1 = copy(end1, end1, out1);
|
||||
VERIFY( out1 == buffer1 );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( wstring(buffer1, out1) == str1 );
|
||||
*out1++ = L'x';
|
||||
VERIFY( wstring(buffer1, out1) == str1 + L'x' );
|
||||
wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t));
|
||||
|
||||
iss1.seekg(0);
|
||||
out1 = buffer1;
|
||||
wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t));
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( wstring(buffer1, out1) == str1 );
|
||||
*out1++ = L'y';
|
||||
VERIFY( wstring(buffer1, out1) == str1 + L'y' );
|
||||
out1 = buffer1;
|
||||
wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t));
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( wstring(buffer1, out1) == L"" );
|
||||
|
||||
iss1.seekg(0);
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( wstring(buffer1, out1) == str1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef ostreambuf_iterator<wchar_t> out_iterator_type;
|
||||
|
||||
const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin";
|
||||
const wstring str1(data1);
|
||||
const wchar_t* beg1 = data1;
|
||||
const wchar_t* end1 = beg1 + str1.size();
|
||||
|
||||
wostringstream oss1;
|
||||
out_iterator_type out1(oss1);
|
||||
|
||||
out1 = copy(beg1, beg1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(end1, end1, out1);
|
||||
VERIFY( oss1.str().empty() );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = L'x';
|
||||
VERIFY( oss1.str() == str1 + L'x' );
|
||||
oss1.str(L"");
|
||||
|
||||
oss1.seekp(0);
|
||||
oss1.str(L"");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
*out1 = L'y';
|
||||
VERIFY( oss1.str() == str1 + L'y' );
|
||||
oss1.str(L"");
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 );
|
||||
|
||||
out1 = copy(beg1, end1, out1);
|
||||
VERIFY( oss1.str() == str1 + str1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<wchar_t> in_iterator_type;
|
||||
|
||||
wifstream fbuf_ref("istream_unformatted-1.txt"),
|
||||
fbuf("istream_unformatted-1.txt");
|
||||
|
||||
wchar_t buffer_ref[16500],
|
||||
buffer[16500];
|
||||
|
||||
fbuf_ref.read(buffer_ref, 16500);
|
||||
|
||||
in_iterator_type beg(fbuf);
|
||||
in_iterator_type end;
|
||||
copy(beg, end, buffer);
|
||||
|
||||
VERIFY( fbuf_ref.good() );
|
||||
VERIFY( fbuf.good() );
|
||||
|
||||
VERIFY( !wmemcmp(buffer, buffer_ref, 16500) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
|
||||
const char data1[] = "Drei Phantasien nach Friedrich Holderlin";
|
||||
const string str1(data1);
|
||||
istringstream iss1(str1);
|
||||
in_iterator_type beg1(iss1);
|
||||
in_iterator_type end1, it1;
|
||||
|
||||
it1 = find(beg1, beg1, 'l');
|
||||
VERIFY( it1 == beg1 );
|
||||
VERIFY( *it1 == 'D' );
|
||||
|
||||
it1 = find(end1, end1, 'D');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
it1 = find(end1, end1, 'Z');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
it1 = find(beg1, end1, 'P');
|
||||
VERIFY( *it1 == 'P' );
|
||||
it1 = find(beg1, end1, 't');
|
||||
VERIFY( *it1 == 't' );
|
||||
++it1;
|
||||
VERIFY( *it1 == 'a' );
|
||||
|
||||
it1 = find(beg1, end1, 'H');
|
||||
VERIFY( *it1 == 'H' );
|
||||
it1 = find(beg1, end1, 'l');
|
||||
VERIFY( *it1 == 'l' );
|
||||
++it1;
|
||||
it1 = find(beg1, end1, 'l');
|
||||
VERIFY( *it1 == 'l' );
|
||||
++it1;
|
||||
VERIFY( *it1 == 'i' );
|
||||
it1 = find(beg1, end1, 'Z');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
it1 = find(beg1, end1, 'D');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
iss1.seekg(0);
|
||||
it1 = find(beg1, end1, 'D');
|
||||
VERIFY( it1 != end1 );
|
||||
VERIFY( *it1 == 'D' );
|
||||
++it1;
|
||||
VERIFY( *it1 == 'r' );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
|
||||
ifstream fbuf("istream_unformatted-1.txt");
|
||||
|
||||
in_iterator_type beg(fbuf);
|
||||
in_iterator_type end;
|
||||
|
||||
unsigned found = 0;
|
||||
for (;;)
|
||||
{
|
||||
beg = find(beg, end, '1');
|
||||
if (beg == end)
|
||||
break;
|
||||
|
||||
++found;
|
||||
VERIFY( *beg == '1' );
|
||||
|
||||
for (unsigned sk = 0; sk < 9; sk++)
|
||||
++beg;
|
||||
VERIFY( *beg == '0' );
|
||||
}
|
||||
VERIFY( found == 1500 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<wchar_t> in_iterator_type;
|
||||
|
||||
const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin";
|
||||
const wstring str1(data1);
|
||||
wistringstream iss1(str1);
|
||||
in_iterator_type beg1(iss1);
|
||||
in_iterator_type end1, it1;
|
||||
|
||||
it1 = find(beg1, beg1, L'l');
|
||||
VERIFY( it1 == beg1 );
|
||||
VERIFY( *it1 == L'D' );
|
||||
|
||||
it1 = find(end1, end1, L'D');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
it1 = find(end1, end1, L'Z');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
it1 = find(beg1, end1, L'P');
|
||||
VERIFY( *it1 == L'P' );
|
||||
it1 = find(beg1, end1, L't');
|
||||
VERIFY( *it1 == L't' );
|
||||
++it1;
|
||||
VERIFY( *it1 == L'a' );
|
||||
|
||||
it1 = find(beg1, end1, L'H');
|
||||
VERIFY( *it1 == L'H' );
|
||||
it1 = find(beg1, end1, L'l');
|
||||
VERIFY( *it1 == L'l' );
|
||||
++it1;
|
||||
it1 = find(beg1, end1, L'l');
|
||||
VERIFY( *it1 == L'l' );
|
||||
++it1;
|
||||
VERIFY( *it1 == L'i' );
|
||||
it1 = find(beg1, end1, L'Z');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
it1 = find(beg1, end1, L'D');
|
||||
VERIFY( it1 == end1 );
|
||||
|
||||
iss1.seekg(0);
|
||||
it1 = find(beg1, end1, L'D');
|
||||
VERIFY( it1 != end1 );
|
||||
VERIFY( *it1 == L'D' );
|
||||
++it1;
|
||||
VERIFY( *it1 == L'r' );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
// 2006-03-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// In the occasion of libstdc++/25482
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using namespace std;
|
||||
|
||||
typedef istreambuf_iterator<wchar_t> in_iterator_type;
|
||||
|
||||
wifstream fbuf("istream_unformatted-1.txt");
|
||||
|
||||
in_iterator_type beg(fbuf);
|
||||
in_iterator_type end;
|
||||
|
||||
unsigned found = 0;
|
||||
for (;;)
|
||||
{
|
||||
beg = find(beg, end, L'1');
|
||||
if (beg == end)
|
||||
break;
|
||||
|
||||
++found;
|
||||
VERIFY( *beg == L'1' );
|
||||
|
||||
for (unsigned sk = 0; sk < 9; sk++)
|
||||
++beg;
|
||||
VERIFY( *beg == L'0' );
|
||||
}
|
||||
VERIFY( found == 1500 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_performance.h>
|
||||
|
||||
// libstdc++/25482
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace __gnu_test;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
typedef ostreambuf_iterator<char> out_iterator_type;
|
||||
|
||||
time_counter time;
|
||||
resource_counter resource;
|
||||
|
||||
const char data[] = "Contrappunto dialettico alla mente";
|
||||
|
||||
// istreambuf iterators -> ostreambuf iterator
|
||||
{
|
||||
istringstream iss(data);
|
||||
in_iterator_type beg(iss);
|
||||
in_iterator_type end;
|
||||
|
||||
ostringstream oss;
|
||||
out_iterator_type out(oss);
|
||||
|
||||
start_counters(time, resource);
|
||||
for (unsigned i = 0; i < 10000000; ++i)
|
||||
{
|
||||
copy(beg, end, out);
|
||||
iss.seekg(0);
|
||||
oss.seekp(0);
|
||||
}
|
||||
stop_counters(time, resource);
|
||||
report_performance(__FILE__, "isb iters -> osb iter", time, resource);
|
||||
clear_counters(time, resource);
|
||||
}
|
||||
|
||||
// char array -> ostreambuf iterator
|
||||
{
|
||||
const char* beg = data;
|
||||
const char* end = data + sizeof(data) - 1;
|
||||
|
||||
ostringstream oss;
|
||||
out_iterator_type out(oss);
|
||||
|
||||
start_counters(time, resource);
|
||||
for (unsigned i = 0; i < 10000000; ++i)
|
||||
{
|
||||
copy(beg, end, out);
|
||||
oss.seekp(0);
|
||||
}
|
||||
stop_counters(time, resource);
|
||||
report_performance(__FILE__, "pointers -> osb iter", time, resource);
|
||||
clear_counters(time, resource);
|
||||
}
|
||||
|
||||
// istreambuf iterators -> char array
|
||||
{
|
||||
istringstream iss(data);
|
||||
in_iterator_type beg(iss);
|
||||
in_iterator_type end;
|
||||
|
||||
char out[sizeof(data)];
|
||||
|
||||
start_counters(time, resource);
|
||||
for (unsigned i = 0; i < 10000000; ++i)
|
||||
{
|
||||
copy(beg, end, out);
|
||||
iss.seekg(0);
|
||||
}
|
||||
stop_counters(time, resource);
|
||||
report_performance(__FILE__, "isb iters -> pointer", time, resource);
|
||||
clear_counters(time, resource);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <testsuite_performance.h>
|
||||
|
||||
// libstdc++/25482
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace __gnu_test;
|
||||
|
||||
typedef istreambuf_iterator<char> in_iterator_type;
|
||||
|
||||
istringstream iss("a0000b1111c2222d3333e4444f5555g6666h7777i8888j9999"
|
||||
"k0000l1111m2222n3333o4444p5555q6666r7777s8888t9999");
|
||||
|
||||
in_iterator_type beg(iss);
|
||||
in_iterator_type end;
|
||||
|
||||
time_counter time;
|
||||
resource_counter resource;
|
||||
|
||||
start_counters(time, resource);
|
||||
for (unsigned i = 0; i < 1000000; ++i)
|
||||
{
|
||||
for (char c = 'a'; c < 'u'; ++c)
|
||||
{
|
||||
find(beg, end, c);
|
||||
iss.seekg(0);
|
||||
}
|
||||
}
|
||||
stop_counters(time, resource);
|
||||
report_performance(__FILE__, "", time, resource);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue