re PR libstdc++/21238 (conflicting "typedef __numpunct_cache<_CharT> __cache_type;" in std::numpunct<CharT> makes specialization impossible)

2005-04-29  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/21238
	* include/bits/locale_facets.tcc (num_get::_M_extract_float,
	num_get::_M_extract_int, num_get::do_get(bool&),
	num_put::_M_insert_int, num_put::_M_insert_float,
	num_put::do_put(bool), money_get::_M_extract,
	money_put::_M_insert): Adjust the __cache_type typedef not to
	forward to a numpunct/moneypunct typedef.
	* testsuite/testsuite_character.h: Add pod_uint and its numpunct
	and moneypunct specializations.
	* testsuite/testsuite_character.cc: Add numpunct<pod_uint>::id
	and moneypunct<pod_uint>::id.
	* testsuite/22_locale/num_get/3.cc: New.
	* testsuite/22_locale/num_put/3.cc: Likewise.
	* testsuite/22_locale/money_get/3.cc: Likewise.
	* testsuite/22_locale/money_put/3.cc: Likewise.

	* include/bits/locale_facets.tcc (money_put::_M_insert,
	time_get::_M_extract_name): Prefer operator== to operator!=
	on char_types.

From-SVN: r99012
This commit is contained in:
Paolo Carlini 2005-04-29 18:50:00 +00:00 committed by Paolo Carlini
parent b61ae8b261
commit a70c902e06
8 changed files with 358 additions and 13 deletions

View File

@ -1,3 +1,25 @@
2005-04-29 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/21238
* include/bits/locale_facets.tcc (num_get::_M_extract_float,
num_get::_M_extract_int, num_get::do_get(bool&),
num_put::_M_insert_int, num_put::_M_insert_float,
num_put::do_put(bool), money_get::_M_extract,
money_put::_M_insert): Adjust the __cache_type typedef not to
forward to a numpunct/moneypunct typedef.
* testsuite/testsuite_character.h: Add pod_uint and its numpunct
and moneypunct specializations.
* testsuite/testsuite_character.cc: Add numpunct<pod_uint>::id
and moneypunct<pod_uint>::id.
* testsuite/22_locale/num_get/3.cc: New.
* testsuite/22_locale/num_put/3.cc: Likewise.
* testsuite/22_locale/money_get/3.cc: Likewise.
* testsuite/22_locale/money_put/3.cc: Likewise.
* include/bits/locale_facets.tcc (money_put::_M_insert,
time_get::_M_extract_name): Prefer operator== to operator!=
on char_types.
2005-04-29 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits (is_convertible): Adjust according

View File

@ -277,7 +277,7 @@ namespace std
ios_base::iostate& __err, string& __xtrc) const
{
typedef char_traits<_CharT> __traits_type;
typedef typename numpunct<_CharT>::__cache_type __cache_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@ -462,8 +462,8 @@ namespace std
ios_base::iostate& __err, _ValueT& __v) const
{
typedef char_traits<_CharT> __traits_type;
typedef typename __to_unsigned_type<_ValueT>::__type __unsigned_type;
typedef typename numpunct<_CharT>::__cache_type __cache_type;
typedef typename __to_unsigned_type<_ValueT>::__type __unsigned_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@ -650,7 +650,7 @@ namespace std
else
{
// Parse bool values as alphanumeric.
typedef typename numpunct<_CharT>::__cache_type __cache_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@ -915,7 +915,7 @@ namespace std
_M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
typedef typename numpunct<_CharT>::__cache_type __cache_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@ -1038,7 +1038,7 @@ namespace std
_M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
typedef typename numpunct<_CharT>::__cache_type __cache_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@ -1165,7 +1165,7 @@ namespace std
}
else
{
typedef typename numpunct<_CharT>::__cache_type __cache_type;
typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@ -1259,8 +1259,7 @@ namespace std
typedef char_traits<_CharT> __traits_type;
typedef typename string_type::size_type size_type;
typedef money_base::part part;
typedef moneypunct<_CharT, _Intl> __moneypunct_type;
typedef typename __moneypunct_type::__cache_type __cache_type;
typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
@ -1518,8 +1517,7 @@ namespace std
{
typedef typename string_type::size_type size_type;
typedef money_base::part part;
typedef moneypunct<_CharT, _Intl> __moneypunct_type;
typedef typename __moneypunct_type::__cache_type __cache_type;
typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
@ -1535,7 +1533,7 @@ namespace std
money_base::pattern __p;
const char_type* __sign;
size_type __sign_size;
if (*__beg != __lit[money_base::_S_minus])
if (!(*__beg == __lit[money_base::_S_minus]))
{
__p = __lc->_M_pos_format;
__sign = __lc->_M_positive_sign;
@ -2020,7 +2018,7 @@ namespace std
for (size_t __i3 = 0; __i3 < __nmatches;)
{
__name = __names[__matches[__i3]];
if (__name[__pos] != *__beg)
if (!(__name[__pos] == *__beg))
__matches[__i3] = __matches[--__nmatches];
else
++__i3;

View File

@ -0,0 +1,41 @@
// 2005-04-29 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.6.1 Template class money_get
// { dg-do compile }
#include <locale>
#include <testsuite_character.h>
class gnu_money_get: public std::money_get<__gnu_test::pod_uint>
{ };
// libstdc++/21238
void test01()
{
gnu_money_get facet01;
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,41 @@
// 2005-04-29 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.6.2 Template class money_put
// { dg-do compile }
#include <locale>
#include <testsuite_character.h>
class gnu_money_put: public std::money_put<__gnu_test::pod_uint>
{ };
// libstdc++/21238
void test01()
{
gnu_money_put facet01;
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,41 @@
// 2005-04-29 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.2.1 Template class num_get
// { dg-do compile }
#include <locale>
#include <testsuite_character.h>
class gnu_num_get: public std::num_get<__gnu_test::pod_uint>
{ };
// libstdc++/21238
void test01()
{
gnu_num_get facet01;
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,41 @@
// 2005-04-29 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.2.2 Template class num_put
// { dg-do compile }
#include <locale>
#include <testsuite_character.h>
class gnu_num_put: public std::num_put<__gnu_test::pod_uint>
{ };
// libstdc++/21238
void test01()
{
gnu_num_put facet01;
}
int main()
{
test01();
return 0;
}

View File

@ -39,6 +39,12 @@ namespace std
locale::id
ctype<__gnu_test::pod_uchar>::id;
locale::id
numpunct<__gnu_test::pod_uint>::id;
locale::id
moneypunct<__gnu_test::pod_uint>::id;
// Member specializations for the existing facet classes.
// NB: This isn't especially portable. Perhaps a better way would be
// to just specialize all of numpunct and ctype.

View File

@ -71,6 +71,7 @@ namespace __gnu_test
typedef character<unsigned char, pod_int, pod_state> pod_char;
typedef character<unsigned char, unsigned int, pod_state> pod_uchar;
typedef character<unsigned short, unsigned int> pod_ushort;
typedef character<unsigned int, unsigned long> pod_uint;
// Specializations.
// pod_char
@ -377,6 +378,160 @@ namespace std
return high;
}
};
// numpunct specializations
template<>
class numpunct<__gnu_test::pod_uint>
: public locale::facet
{
public:
typedef __gnu_test::pod_uint char_type;
typedef basic_string<char_type> string_type;
static locale::id id;
explicit
numpunct(size_t refs = 0)
: locale::facet(refs)
{ }
char_type
decimal_point() const
{ return this->do_decimal_point(); }
char_type
thousands_sep() const
{ return this->do_thousands_sep(); }
string
grouping() const
{ return this->do_grouping(); }
string_type
truename() const
{ return this->do_truename(); }
string_type
falsename() const
{ return this->do_falsename(); }
protected:
~numpunct()
{ }
virtual char_type
do_decimal_point() const
{ return char_type(); }
virtual char_type
do_thousands_sep() const
{ return char_type(); }
virtual string
do_grouping() const
{ return string(); }
virtual string_type
do_truename() const
{ return string_type(); }
virtual string_type
do_falsename() const
{ return string_type(); }
};
template<>
class moneypunct<__gnu_test::pod_uint>
: public locale::facet, public money_base
{
public:
typedef __gnu_test::pod_uint char_type;
typedef basic_string<char_type> string_type;
static locale::id id;
static const bool intl = false;
explicit
moneypunct(size_t refs = 0)
: locale::facet(refs)
{ }
char_type
decimal_point() const
{ return this->do_decimal_point(); }
char_type
thousands_sep() const
{ return this->do_thousands_sep(); }
string
grouping() const
{ return this->do_grouping(); }
string_type
curr_symbol() const
{ return this->do_curr_symbol(); }
string_type
positive_sign() const
{ return this->do_positive_sign(); }
string_type
negative_sign() const
{ return this->do_negative_sign(); }
int
frac_digits() const
{ return this->do_frac_digits(); }
pattern
pos_format() const
{ return this->do_pos_format(); }
pattern
neg_format() const
{ return this->do_neg_format(); }
protected:
~moneypunct()
{ }
virtual char_type
do_decimal_point() const
{ return char_type(); }
virtual char_type
do_thousands_sep() const
{ return char_type(); }
virtual string
do_grouping() const
{ return string(); }
virtual string_type
do_curr_symbol() const
{ return string_type(); }
string_type
do_positive_sign() const
{ return string_type(); }
string_type
do_negative_sign() const
{ return string_type(); }
int
do_frac_digits() const
{ return 0; }
pattern
do_pos_format() const
{ return pattern(); }
pattern
do_neg_format() const
{ return pattern(); }
};
} // namespace std
#endif // _GLIBCXX_TESTSUITE_CHARACTER_H