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
to the resolution of TR1 issue 3.20.
* testsuite/tr1/4_metaprogramming/relationships_between_types/
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);
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);
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);
_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);
_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);
}
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);
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);
{
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);
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;
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;
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}
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.
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
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