From f7192a24dca80116f2179afbb38e7ae29b5db9fe Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Wed, 31 Jul 2002 02:47:36 +0000 Subject: 2002-07-30 Benjamin Kosnik Gabriel Dos Reis * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@55893 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/testsuite/21_strings/capacity.cc | 87 +++++++++++ .../22_locale/codecvt_members_unicode_char.cc | 68 ++++++++- .../22_locale/codecvt_members_unicode_wchar_t.cc | 69 ++++++++- libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc | 63 +++++++- libstdc++-v3/testsuite/27_io/filebuf.cc | 58 ++++++- libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc | 49 ------ libstdc++-v3/testsuite/27_io/fstream.cc | 2 + libstdc++-v3/testsuite/27_io/ios_init.cc | 170 +++++++++++++++++++++ libstdc++-v3/testsuite/27_io/istream.cc | 2 + libstdc++-v3/testsuite/27_io/ostream.cc | 2 + libstdc++-v3/testsuite/27_io/streambuf.cc | 2 + libstdc++-v3/testsuite/27_io/stringbuf.cc | 2 + libstdc++-v3/testsuite/27_io/stringstream.cc | 2 + libstdc++-v3/testsuite/testsuite_hooks.h | 82 +++++++++- 14 files changed, 596 insertions(+), 62 deletions(-) (limited to 'libstdc++-v3/testsuite') diff --git a/libstdc++-v3/testsuite/21_strings/capacity.cc b/libstdc++-v3/testsuite/21_strings/capacity.cc index be209e07e0c..3c45b005017 100644 --- a/libstdc++-v3/testsuite/21_strings/capacity.cc +++ b/libstdc++-v3/testsuite/21_strings/capacity.cc @@ -36,6 +36,93 @@ template struct B { }; +// char_traits specialization +namespace std +{ + template<> + struct char_traits > + { + typedef A char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type& __c) + { return char_type(); } + + static int_type + to_int_type(const char_type& __c) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; +} // namespace std + void test01() { // 1 POD types : resize, capacity, reserve diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc b/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc index 0d0d1d5bcad..51bf9b9600a 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc @@ -23,10 +23,71 @@ #include #include -using namespace std; + #ifdef _GLIBCPP_USE___ENC_TRAITS +// Need some char_traits specializations for this to work. +typedef unsigned short unicode_t; + +namespace std +{ + template<> + struct char_traits + { + typedef unicode_t char_type; + // Unsigned as wint_t is unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return static_cast(memcpy(__s1, __s2, __n)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; +} + /* > how do I check that these conversions are correct? Very easy. Since all the characters are from ASCII you simply @@ -51,7 +112,7 @@ it shows that the other byte-order is used (25856 == 0x6500). void -initialize_state(__enc_traits& state) +initialize_state(std::__enc_traits& state) { state._M_init(); } // Partial specialization using __enc_traits. @@ -59,8 +120,8 @@ initialize_state(__enc_traits& state) // UNICODE - UCS2 (big endian) void test01() { + using namespace std; typedef codecvt_base::result result; - typedef unsigned short unicode_t; typedef unicode_t int_type; typedef char ext_type; typedef __enc_traits enc_type; @@ -146,6 +207,7 @@ void test01() // UNICODE - UCS2 (little endian) void test02() { + using namespace std; typedef codecvt_base::result result; typedef unsigned short unicode_t; typedef unicode_t int_type; diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc index 87a2f05bf6c..c944865b08f 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc @@ -1,6 +1,6 @@ // 2000-08-23 Benjamin Kosnik -// Copyright (C) 2000, 2001 Free Software Foundation +// Copyright (C) 2000, 2001, 2002 Free Software Foundation // // 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 @@ -23,21 +23,80 @@ #include #include -using namespace std; - #ifdef _GLIBCPP_USE___ENC_TRAITS #ifdef _GLIBCPP_USE_WCHAR_T +// Need some char_traits specializations for this to work. +typedef unsigned short unicode_t; + +namespace std +{ + template<> + struct char_traits + { + typedef unicode_t char_type; + // Unsigned as wint_t is unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return static_cast(memcpy(__s1, __s2, __n)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; +} + void -initialize_state(__enc_traits& state) +initialize_state(std::__enc_traits& state) { state._M_init(); } // Partial specialization using __enc_traits. // codecvt void test01() { + using namespace std; typedef codecvt_base::result result; - typedef unsigned short unicode_t; typedef unicode_t int_type; typedef wchar_t ext_type; typedef __enc_traits enc_type; diff --git a/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc b/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc index 732ec1714aa..94db3bcc139 100644 --- a/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc +++ b/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc @@ -48,11 +48,70 @@ public: std::locale::id gnu_facet::id; +// Need some char_traits specializations for this to work. +typedef unsigned short unicode_t; + +namespace std +{ + template<> + struct char_traits + { + typedef unicode_t char_type; + // Unsigned as wint_t is unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return static_cast(memcpy(__s1, __s2, __n)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; +} + void test01() { using namespace std; - - typedef unsigned short unicode_t; typedef unicode_t int_type; typedef char ext_type; typedef __enc_traits enc_type; diff --git a/libstdc++-v3/testsuite/27_io/filebuf.cc b/libstdc++-v3/testsuite/27_io/filebuf.cc index 9919365a552..e72f2ca8f6f 100644 --- a/libstdc++-v3/testsuite/27_io/filebuf.cc +++ b/libstdc++-v3/testsuite/27_io/filebuf.cc @@ -42,11 +42,67 @@ void test01() // test05 // libstdc++/1886 // should be able to instantiate basic_filebuf for non-standard types. -template class std::basic_filebuf >; +namespace test +{ + using namespace std; + typedef short type_t; + template class basic_filebuf >; + template class basic_filebuf >; +} // test + + +// test07 +// libstdc++/2020 +// should be able to use custom char_type +class gnu_char_type +{ + unsigned long character; +public: + // operator == + bool + operator==(const gnu_char_type& __lhs) + { return character == __lhs.character; } + + // operator < + bool + operator<(const gnu_char_type& __lhs) + { return character < __lhs.character; } + + // default ctor + gnu_char_type() { } + + // to_char_type + gnu_char_type(const unsigned long& __l) : character(__l) { } + + // to_int_type + operator unsigned long() const { return character; } +}; + +void test07() +{ + bool test = true; + typedef std::basic_filebuf gnu_filebuf; + + try + { gnu_filebuf obj; } + catch(std::exception& obj) + { + test = false; + VERIFY( test ); + } +} + +#if !__GXX_WEAK__ +// Explicitly instantiate for systems with no COMDAT or weak support. +template + std::basic_streambuf::int_type + std::basic_streambuf::_S_pback_size; +#endif int main() { test01(); + test07(); return 0; } diff --git a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc index fb370c36e50..0a92788296a 100644 --- a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc +++ b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc @@ -514,54 +514,6 @@ void test06() VERIFY( buffer[0] == 'a' ); } -// test06 -// libstdc++/2020 -// should be able to use custom char_type -class gnu_char_type -{ - unsigned long character; -public: - // operator == - bool - operator==(const gnu_char_type& __lhs) - { return character == __lhs.character; } - - // operator < - bool - operator<(const gnu_char_type& __lhs) - { return character < __lhs.character; } - - // default ctor - gnu_char_type() { } - - // to_char_type - gnu_char_type(const unsigned long& __l) : character(__l) { } - - // to_int_type - operator unsigned long() const { return character; } -}; - -void test07() -{ - bool test = true; - typedef std::basic_filebuf gnu_filebuf; - - try - { gnu_filebuf obj; } - catch(std::exception& obj) - { - test = false; - VERIFY( test ); - } -} - -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_streambuf::int_type - std::basic_streambuf::_S_pback_size; -#endif - main() { test01(); @@ -571,7 +523,6 @@ main() test04(); test05(); test06(); - test07(); return 0; } diff --git a/libstdc++-v3/testsuite/27_io/fstream.cc b/libstdc++-v3/testsuite/27_io/fstream.cc index 2ecd0778700..276294d9c9d 100644 --- a/libstdc++-v3/testsuite/27_io/fstream.cc +++ b/libstdc++-v3/testsuite/27_io/fstream.cc @@ -31,6 +31,7 @@ // NB: This file is for testing basic_fstream with NO OTHER INCLUDES. #include +#include // { dg-do compile } @@ -51,6 +52,7 @@ namespace test using namespace std; typedef short type_t; template class basic_fstream >; + template class basic_fstream >; } // test int main() diff --git a/libstdc++-v3/testsuite/27_io/ios_init.cc b/libstdc++-v3/testsuite/27_io/ios_init.cc index 1905aa64ac8..33a52de9470 100644 --- a/libstdc++-v3/testsuite/27_io/ios_init.cc +++ b/libstdc++-v3/testsuite/27_io/ios_init.cc @@ -34,6 +34,176 @@ #include #include +// char_traits specialization +namespace std +{ + template<> + struct char_traits + { + typedef unsigned short char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type& __c) + { return char_type(); } + + static int_type + to_int_type(const char_type& __c) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; + + template<> + struct char_traits + { + typedef unsigned char char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p && *__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type& __c) + { return char_type(); } + + static int_type + to_int_type(const char_type& __c) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; +} // namespace std + class gnu_filebuf: public std::filebuf { int i; diff --git a/libstdc++-v3/testsuite/27_io/istream.cc b/libstdc++-v3/testsuite/27_io/istream.cc index 05db50ed461..6cec904eb67 100644 --- a/libstdc++-v3/testsuite/27_io/istream.cc +++ b/libstdc++-v3/testsuite/27_io/istream.cc @@ -31,6 +31,7 @@ // NB: This file is for testing istream with NO OTHER INCLUDES. #include +#include // { dg-do compile } @@ -51,6 +52,7 @@ namespace test using namespace std; typedef short type_t; template class basic_istream >; + template class basic_istream >; } // test int main() diff --git a/libstdc++-v3/testsuite/27_io/ostream.cc b/libstdc++-v3/testsuite/27_io/ostream.cc index ae524ec61f2..ee764f9d697 100644 --- a/libstdc++-v3/testsuite/27_io/ostream.cc +++ b/libstdc++-v3/testsuite/27_io/ostream.cc @@ -31,6 +31,7 @@ // NB: This file is for testing ostream with NO OTHER INCLUDES. #include +#include // { dg-do compile } @@ -51,6 +52,7 @@ namespace test using namespace std; typedef short type_t; template class basic_ostream >; + template class basic_ostream >; } // test int main() diff --git a/libstdc++-v3/testsuite/27_io/streambuf.cc b/libstdc++-v3/testsuite/27_io/streambuf.cc index 905dee089de..102ff60c260 100644 --- a/libstdc++-v3/testsuite/27_io/streambuf.cc +++ b/libstdc++-v3/testsuite/27_io/streambuf.cc @@ -31,6 +31,7 @@ // NB: This file is for testing basic_streambuf with NO OTHER INCLUDES. #include +#include // { dg-do compile } @@ -51,6 +52,7 @@ namespace test using namespace std; typedef short type_t; template class basic_streambuf >; + template class basic_streambuf >; } // test int main() diff --git a/libstdc++-v3/testsuite/27_io/stringbuf.cc b/libstdc++-v3/testsuite/27_io/stringbuf.cc index 00825b6b69c..3cfd5af605c 100644 --- a/libstdc++-v3/testsuite/27_io/stringbuf.cc +++ b/libstdc++-v3/testsuite/27_io/stringbuf.cc @@ -31,6 +31,7 @@ // NB: This file is for testing basic_stringbuf with NO OTHER INCLUDES. #include +#include // { dg-do compile } @@ -51,6 +52,7 @@ namespace test using namespace std; typedef short type_t; template class basic_stringbuf >; + template class basic_stringbuf >; } // test int main() diff --git a/libstdc++-v3/testsuite/27_io/stringstream.cc b/libstdc++-v3/testsuite/27_io/stringstream.cc index 1a1b0178074..cb9e39d9588 100644 --- a/libstdc++-v3/testsuite/27_io/stringstream.cc +++ b/libstdc++-v3/testsuite/27_io/stringstream.cc @@ -31,6 +31,7 @@ // NB: This file is for testing basic_stringstream with NO OTHER INCLUDES. #include +#include // { dg-do compile } @@ -51,6 +52,7 @@ namespace test using namespace std; typedef short type_t; template class basic_stringstream >; + template class basic_stringstream >; } // test int main() diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h index a4be70a9b23..5725debe7e8 100644 --- a/libstdc++-v3/testsuite/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/testsuite_hooks.h @@ -50,10 +50,16 @@ // 4) gnu_copy_tracker, from Stephen M. Webb . // A class with nontrivial ctor/dtor that provides the ability to track the // number of copy ctors and dtors, and will throw on demand during copy. +// +// 5) gnu_char, gnu_char_traits, abstract character classes and +// char_traits specializations for testing instantiations. #ifndef _GLIBCPP_TESTSUITE_HOOKS_H #define _GLIBCPP_TESTSUITE_HOOKS_H +#include +#include + #ifdef DEBUG_ASSERT # include # define VERIFY(fn) assert(fn) @@ -61,8 +67,6 @@ # define VERIFY(fn) test &= (fn) #endif -#include - // Defined in GLIBCPP_CONFIGURE_TESTSUITE. #ifndef _GLIBCPP_MEM_LIMITS // Don't do memory limits. @@ -146,6 +150,80 @@ class gnu_copy_tracker static int itsDtorCount; }; +struct gnu_char +{ + unsigned long c; +}; + +struct gnu_int +{ + unsigned long i; +}; + +struct gnu_state +{ + unsigned long l; + unsigned long l2; +}; + +// char_traits specialization +namespace std +{ + template + struct char_traits; + + template<> + struct char_traits + { + typedef gnu_char char_type; + typedef gnu_int int_type; + typedef long pos_type; + typedef unsigned long off_type; + typedef gnu_state state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n); + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; +} // namespace std #endif // _GLIBCPP_TESTSUITE_HOOKS_H -- cgit v1.2.3