acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove.
2001-05-30 Benjamin Kosnik <bkoz@redat.com> * acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. (_GLIBCPP_BUGGY_COMPLEX): Remove. * config.h.in: Regenerate. * acinclude.m4 (GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT): Remove. * aclocal.m4: Regenerate. * configure.in: Don't call it. * configure: Regenerate. libstdc++/2970 * src/complex_io.cc (operator<<(ostream&, const complex&): Fix. * testsuite/26_numerics/complex_inserters_extractors.cc (test01): New test. libstdc++/2985 * include/bits/std_complex.h: Include sstream. Put definitions for complex inserters and extractors here, and remove them from... * src/complex_io.cc: ...here. * include/bits/basic_ios.h (basic_ios::__numput_type): Add _Traits parameter. (basic_ios::__numget_type): Same. * include/bits/std_istream.h: Same. * include/bits/std_ostream.h: Same. * include/bits/sbuf_iter.h (ostreambuf_iterator): Fix typo in base class iterator template arguments. * src/locale-inst.cc: Add explicit has_facet instantiations. * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. (_M_get_fnumput): Remove. (_M_get_fnumget): Remove. (basic_ios::_M_check_facet): New function. (basic_ios::_M_cache_facets): New function. * include/bits/basic_ios.tcc: Definition for _M_cache_facets. (basic_ios::imbue): Call _M_cache_facets. (basic_ios::init): Same. * include/bits/istream.tcc: Format, use _M_check_facet. * include/bits/ostream.tcc: Same. * include/bits/locale_facets.tcc (__output_float): Change signature, add _Traits. * testsuite/26_numerics/complex_inserters_extractors.cc (test02): New test. From-SVN: r42743
This commit is contained in:
parent
20293b4c1b
commit
bfa1e6b11b
21 changed files with 1636 additions and 1876 deletions
|
@ -1,3 +1,45 @@
|
|||
2001-05-30 Benjamin Kosnik <bkoz@redat.com>
|
||||
|
||||
* acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove.
|
||||
(_GLIBCPP_BUGGY_COMPLEX): Remove.
|
||||
* config.h.in: Regenerate.
|
||||
* acinclude.m4 (GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT): Remove.
|
||||
* aclocal.m4: Regenerate.
|
||||
* configure.in: Don't call it.
|
||||
* configure: Regenerate.
|
||||
|
||||
libstdc++/2970
|
||||
* src/complex_io.cc (operator<<(ostream&, const complex&): Fix.
|
||||
* testsuite/26_numerics/complex_inserters_extractors.cc (test01):
|
||||
New test.
|
||||
|
||||
libstdc++/2985
|
||||
* include/bits/std_complex.h: Include sstream. Put definitions for
|
||||
complex inserters and extractors here, and remove them from...
|
||||
* src/complex_io.cc: ...here.
|
||||
* include/bits/basic_ios.h (basic_ios::__numput_type): Add _Traits
|
||||
parameter.
|
||||
(basic_ios::__numget_type): Same.
|
||||
* include/bits/std_istream.h: Same.
|
||||
* include/bits/std_ostream.h: Same.
|
||||
* include/bits/sbuf_iter.h (ostreambuf_iterator): Fix typo in base
|
||||
class iterator template arguments.
|
||||
* src/locale-inst.cc: Add explicit has_facet instantiations.
|
||||
* include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove.
|
||||
(_M_get_fnumput): Remove.
|
||||
(_M_get_fnumget): Remove.
|
||||
(basic_ios::_M_check_facet): New function.
|
||||
(basic_ios::_M_cache_facets): New function.
|
||||
* include/bits/basic_ios.tcc: Definition for _M_cache_facets.
|
||||
(basic_ios::imbue): Call _M_cache_facets.
|
||||
(basic_ios::init): Same.
|
||||
* include/bits/istream.tcc: Format, use _M_check_facet.
|
||||
* include/bits/ostream.tcc: Same.
|
||||
* include/bits/locale_facets.tcc (__output_float): Change
|
||||
signature, add _Traits.
|
||||
* testsuite/26_numerics/complex_inserters_extractors.cc (test02):
|
||||
New test.
|
||||
|
||||
2001-05-30 Loren J. Rittle <ljrittle@acm.org>
|
||||
|
||||
* include/bits/c++config (__USE_MALLOC): Do not define it.
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
// acconfig.h symbols and macros for libstdc++ v3 -*- C++ -*-
|
||||
|
||||
// Define if GCC support for __complex__ float is buggy.
|
||||
#undef _GLIBCPP_BUGGY_FLOAT_COMPLEX
|
||||
|
||||
// Define if GCC support for __complex__ is buggy.
|
||||
#undef _GLIBCPP_BUGGY_COMPLEX
|
||||
|
||||
// Include support for multiple threads, e.g., in the I/O package.
|
||||
#undef _GLIBCPP_USE_THREADS
|
||||
|
||||
|
|
|
@ -863,75 +863,6 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
|
|||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check to see if this version of GNU C++ is afflicted by bugs in
|
||||
dnl __complex__ float support.
|
||||
dnl
|
||||
dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
|
||||
dnl
|
||||
dnl Check to see if this version of GNU C++ is afflicted by bugs in
|
||||
dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
|
||||
dnl gcc-2.95.x when using the library, unless we define the default copy
|
||||
dnl ctor in the specializations of complex<>.
|
||||
dnl
|
||||
dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
|
||||
dnl GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
|
||||
AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT, [
|
||||
AC_REQUIRE([AC_PROG_CXX])
|
||||
|
||||
AC_MSG_CHECKING([for GNU C++ __complex__ support])
|
||||
AC_CACHE_VAL(glibcpp_cv_complex, [
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
|
||||
dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
|
||||
[ dcomplex x; f(x); ],
|
||||
glibcpp_cv_complex=ok,
|
||||
glibcpp_cv_complex=buggy
|
||||
)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
AC_MSG_RESULT($glibcpp_cv_complex)
|
||||
if test $glibcpp_cv_complex = buggy; then
|
||||
AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for GNU C++ __complex__ float support])
|
||||
AC_CACHE_VAL(glibcpp_cv_float_complex, [
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
rm -f conftest.h
|
||||
cat > conftest.h <<EOB
|
||||
//
|
||||
// Check for buggy __complex__ that causes ICE in most versions of egcs
|
||||
// and gcc-2.95.x on certain platforms (eg., x86-win32).
|
||||
//
|
||||
// See http://gcc.gnu.org/ml/gcc-bugs/1999-07n/msg00845.html for
|
||||
// more info on the bug itself.
|
||||
//
|
||||
struct
|
||||
float_complex
|
||||
{
|
||||
__complex__ float m_value;
|
||||
float_complex (float = 0.0f, float = 0.0f);
|
||||
float_complex (__complex__ float val) : m_value (val) {}
|
||||
float_complex foo (const float_complex &val)
|
||||
{ return float_complex (~val.m_value); }
|
||||
};
|
||||
EOB
|
||||
AC_TRY_COMPILE([#include "conftest.h"], ,
|
||||
glibcpp_cv_float_complex=ok,
|
||||
glibcpp_cv_float_complex=buggy
|
||||
)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
AC_MSG_RESULT($glibcpp_cv_float_complex)
|
||||
if test $glibcpp_cv_float_complex = buggy; then
|
||||
AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check for special debugging mode; not for production use.
|
||||
dnl
|
||||
|
|
69
libstdc++-v3/aclocal.m4
vendored
69
libstdc++-v3/aclocal.m4
vendored
|
@ -875,75 +875,6 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
|
|||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check to see if this version of GNU C++ is afflicted by bugs in
|
||||
dnl __complex__ float support.
|
||||
dnl
|
||||
dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
|
||||
dnl
|
||||
dnl Check to see if this version of GNU C++ is afflicted by bugs in
|
||||
dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
|
||||
dnl gcc-2.95.x when using the library, unless we define the default copy
|
||||
dnl ctor in the specializations of complex<>.
|
||||
dnl
|
||||
dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
|
||||
dnl GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
|
||||
AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT, [
|
||||
AC_REQUIRE([AC_PROG_CXX])
|
||||
|
||||
AC_MSG_CHECKING([for GNU C++ __complex__ support])
|
||||
AC_CACHE_VAL(glibcpp_cv_complex, [
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
|
||||
dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
|
||||
[ dcomplex x; f(x); ],
|
||||
glibcpp_cv_complex=ok,
|
||||
glibcpp_cv_complex=buggy
|
||||
)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
AC_MSG_RESULT($glibcpp_cv_complex)
|
||||
if test $glibcpp_cv_complex = buggy; then
|
||||
AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for GNU C++ __complex__ float support])
|
||||
AC_CACHE_VAL(glibcpp_cv_float_complex, [
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
rm -f conftest.h
|
||||
cat > conftest.h <<EOB
|
||||
//
|
||||
// Check for buggy __complex__ that causes ICE in most versions of egcs
|
||||
// and gcc-2.95.x on certain platforms (eg., x86-win32).
|
||||
//
|
||||
// See http://gcc.gnu.org/ml/gcc-bugs/1999-07n/msg00845.html for
|
||||
// more info on the bug itself.
|
||||
//
|
||||
struct
|
||||
float_complex
|
||||
{
|
||||
__complex__ float m_value;
|
||||
float_complex (float = 0.0f, float = 0.0f);
|
||||
float_complex (__complex__ float val) : m_value (val) {}
|
||||
float_complex foo (const float_complex &val)
|
||||
{ return float_complex (~val.m_value); }
|
||||
};
|
||||
EOB
|
||||
AC_TRY_COMPILE([#include "conftest.h"], ,
|
||||
glibcpp_cv_float_complex=ok,
|
||||
glibcpp_cv_float_complex=buggy
|
||||
)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
AC_MSG_RESULT($glibcpp_cv_float_complex)
|
||||
if test $glibcpp_cv_float_complex = buggy; then
|
||||
AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check for special debugging mode; not for production use.
|
||||
dnl
|
||||
|
|
|
@ -3,12 +3,6 @@
|
|||
/* Define if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
// Define if GCC support for __complex__ float is buggy.
|
||||
#undef _GLIBCPP_BUGGY_FLOAT_COMPLEX
|
||||
|
||||
// Define if GCC support for __complex__ is buggy.
|
||||
#undef _GLIBCPP_BUGGY_COMPLEX
|
||||
|
||||
// Include support for multiple threads, e.g., in the I/O package.
|
||||
#undef _GLIBCPP_USE_THREADS
|
||||
|
||||
|
|
1943
libstdc++-v3/configure
vendored
1943
libstdc++-v3/configure
vendored
File diff suppressed because it is too large
Load diff
|
@ -169,7 +169,6 @@ if test -n "$with_cross_host"; then
|
|||
AC_DEFINE(HAVE_TANHL)
|
||||
fi
|
||||
GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
|
||||
GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
|
||||
GLIBCPP_CHECK_WCHAR_T_SUPPORT
|
||||
os_include_dir="config/os/gnu-linux"
|
||||
# GLIBCPP_CHECK_STDLIB_SUPPORT
|
||||
|
@ -189,8 +188,6 @@ if test -n "$with_cross_host"; then
|
|||
|
||||
os_include_dir="config/os/newlib"
|
||||
|
||||
AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
|
||||
AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
|
||||
# need to check for faster f versions of math functions, ie sinf?
|
||||
;;
|
||||
esac
|
||||
|
@ -213,7 +210,6 @@ else
|
|||
GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
|
||||
GLIBCPP_CHECK_MATH_SUPPORT
|
||||
GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
|
||||
GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
|
||||
GLIBCPP_CHECK_WCHAR_T_SUPPORT
|
||||
GLIBCPP_CHECK_STDLIB_SUPPORT
|
||||
|
||||
|
|
|
@ -35,14 +35,13 @@
|
|||
#include <bits/sbuf_iter.h>
|
||||
#include <bits/locale_facets.h>
|
||||
|
||||
namespace std {
|
||||
|
||||
namespace std
|
||||
{
|
||||
// 27.4.5 Template class basic_ios
|
||||
template<typename _CharT, typename _Traits>
|
||||
class basic_ios : public ios_base
|
||||
{
|
||||
public:
|
||||
|
||||
// Types:
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
|
@ -51,11 +50,10 @@ namespace std {
|
|||
typedef _Traits traits_type;
|
||||
|
||||
// Non-standard Types:
|
||||
typedef ctype<_CharT> __ctype_type;
|
||||
// From ostream
|
||||
typedef ostreambuf_iterator<_CharT> __ostreambuf_iter;
|
||||
typedef ctype<_CharT> __ctype_type;
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
|
||||
typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
|
||||
typedef istreambuf_iterator<_CharT> __istreambuf_iter;
|
||||
typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
|
||||
typedef num_get<_CharT, __istreambuf_iter> __numget_type;
|
||||
|
||||
// Data members:
|
||||
|
@ -76,19 +74,10 @@ namespace std {
|
|||
const __numget_type* _M_fnumget;
|
||||
|
||||
public:
|
||||
|
||||
inline const __ctype_type*
|
||||
_M_get_fctype_ios(void)
|
||||
{ return _M_ios_fctype; }
|
||||
|
||||
inline const __numget_type*
|
||||
_M_get_fnumget(void)
|
||||
{ return _M_fnumget; }
|
||||
|
||||
inline const __numput_type*
|
||||
_M_get_fnumput(void)
|
||||
{ return _M_fnumput; }
|
||||
|
||||
operator void*() const
|
||||
{ return this->fail() ? 0 : const_cast<basic_ios*>(this); }
|
||||
|
||||
|
@ -202,8 +191,21 @@ namespace std {
|
|||
|
||||
void
|
||||
init(basic_streambuf<_CharT, _Traits>* __sb);
|
||||
|
||||
bool
|
||||
_M_check_facet(const locale::facet* __f)
|
||||
{
|
||||
bool __ret = false;
|
||||
if (__f)
|
||||
__ret = true;
|
||||
else
|
||||
__throw_bad_cast();
|
||||
return __ret;
|
||||
}
|
||||
|
||||
void
|
||||
_M_cache_facets(const locale& __loc);
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
|
||||
|
|
|
@ -105,9 +105,7 @@ namespace std {
|
|||
{
|
||||
locale __old(this->getloc());
|
||||
ios_base::imbue(__loc);
|
||||
_M_ios_fctype = &use_facet<__ctype_type>(__loc);
|
||||
_M_fnumput = &use_facet<__numput_type>(__loc);
|
||||
_M_fnumget = &use_facet<__numget_type>(__loc);
|
||||
_M_cache_facets(__loc);
|
||||
if (this->rdbuf() != 0)
|
||||
this->rdbuf()->pubimbue(__loc);
|
||||
return __old;
|
||||
|
@ -119,10 +117,7 @@ namespace std {
|
|||
{
|
||||
// NB: This may be called more than once on the same object.
|
||||
ios_base::_M_init();
|
||||
_M_ios_fctype = &use_facet<__ctype_type>(_M_ios_locale);
|
||||
// Should be filled in by ostream and istream, respectively.
|
||||
_M_fnumput = &use_facet<__numput_type>(_M_ios_locale);
|
||||
_M_fnumget = &use_facet<__numget_type>(_M_ios_locale);
|
||||
_M_cache_facets(_M_ios_locale);
|
||||
_M_tie = 0;
|
||||
_M_fill = this->widen(' ');
|
||||
_M_exception = goodbit;
|
||||
|
@ -130,8 +125,21 @@ namespace std {
|
|||
_M_streambuf_state = __sb ? goodbit : badbit;
|
||||
}
|
||||
|
||||
template<typename _CharT, typename _Traits>
|
||||
void
|
||||
basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
|
||||
{
|
||||
if (has_facet<__ctype_type>(__loc))
|
||||
_M_ios_fctype = &use_facet<__ctype_type>(__loc);
|
||||
// Should be filled in by ostream and istream, respectively.
|
||||
if (has_facet<__numput_type>(__loc))
|
||||
_M_fnumput = &use_facet<__numput_type>(__loc);
|
||||
if (has_facet<__numget_type>(__loc))
|
||||
_M_fnumget = &use_facet<__numget_type>(__loc);
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif // _CPP_BITS_BASICIOS_TCC
|
||||
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -964,7 +964,7 @@ namespace std
|
|||
#endif
|
||||
|
||||
// Generic helper function
|
||||
template<typename _CharT, typename _OutIter>
|
||||
template<typename _CharT, typename _Traits, typename _OutIter>
|
||||
_OutIter
|
||||
__output_float(_OutIter __s, ios_base& __io, _CharT __fill,
|
||||
const char* __sptr, size_t __slen)
|
||||
|
@ -974,10 +974,10 @@ namespace std
|
|||
}
|
||||
|
||||
// Partial specialization for ostreambuf_iterator.
|
||||
template<typename _CharT>
|
||||
ostreambuf_iterator<_CharT>
|
||||
__output_float(ostreambuf_iterator<_CharT> __s, ios_base& __io,
|
||||
_CharT __fill, const char* __sptr, size_t __slen)
|
||||
template<typename _CharT, typename _Traits>
|
||||
ostreambuf_iterator<_CharT, _Traits>
|
||||
__output_float(ostreambuf_iterator<_CharT, _Traits> __s, ios_base& __io,
|
||||
_CharT __fill, const char* __sptr, size_t __slen)
|
||||
{
|
||||
size_t __padding = __io.width() > streamsize(__slen) ?
|
||||
__io.width() -__slen : 0;
|
||||
|
@ -1037,7 +1037,7 @@ namespace std
|
|||
if (__prec > __max_prec)
|
||||
__prec = __max_prec;
|
||||
// The *2 provides for signs, exp, 'E', and pad.
|
||||
char __sbuf[__max_prec*2];
|
||||
char __sbuf[__max_prec * 2];
|
||||
size_t __slen;
|
||||
// Long enough for the max format spec.
|
||||
char __fbuf[16];
|
||||
|
@ -1061,7 +1061,7 @@ namespace std
|
|||
if (__prec > __max_prec)
|
||||
__prec = __max_prec;
|
||||
// The *2 provides for signs, exp, 'E', and pad.
|
||||
char __sbuf[__max_prec*2];
|
||||
char __sbuf[__max_prec * 2];
|
||||
size_t __slen;
|
||||
// Long enough for the max format spec.
|
||||
char __fbuf[16];
|
||||
|
|
|
@ -118,8 +118,9 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -142,16 +143,21 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
bool __f;
|
||||
char_type __c = this->fill();
|
||||
ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
|
||||
if (__fmt & ios_base::oct || __fmt & ios_base::hex)
|
||||
__f = _M_fnumput->put(*this, *this, this->fill(),
|
||||
static_cast<unsigned long>(__n)).failed();
|
||||
else
|
||||
__f = _M_fnumput->put(*this, *this, this->fill(), __n).failed();
|
||||
|
||||
if (__f)
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
{
|
||||
bool __b = false;
|
||||
if (__fmt & ios_base::oct || __fmt & ios_base::hex)
|
||||
{
|
||||
unsigned long __l = static_cast<unsigned long>(__n);
|
||||
__b = _M_fnumput->put(*this, *this, __c, __l).failed();
|
||||
}
|
||||
else
|
||||
__b = _M_fnumput->put(*this, *this, __c, __n).failed();
|
||||
if (__b)
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -174,8 +180,9 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -199,15 +206,22 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
bool __f;
|
||||
char_type __c = this->fill();
|
||||
ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
|
||||
if (__fmt & ios_base::oct || __fmt & ios_base::hex)
|
||||
__f = _M_fnumput->put(*this, *this, this->fill(),
|
||||
static_cast<unsigned long long>(__n)).failed();
|
||||
else
|
||||
__f = _M_fnumput->put(*this, *this, this->fill(), __n).failed();
|
||||
if (__f)
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
{
|
||||
bool __b = false;
|
||||
if (__fmt & ios_base::oct || __fmt & ios_base::hex)
|
||||
{
|
||||
unsigned long long __l;
|
||||
__l = static_cast<unsigned long long>(__n);
|
||||
__b = _M_fnumput->put(*this, *this, __c, __l).failed();
|
||||
}
|
||||
else
|
||||
__b = _M_fnumput->put(*this, *this, __c, __n).failed();
|
||||
if (__b)
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -230,8 +244,9 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -255,8 +270,9 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -279,8 +295,9 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
@ -303,8 +320,9 @@ namespace std
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
if (_M_check_facet(_M_fnumput))
|
||||
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
catch(exception& __fail)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace std
|
|||
{
|
||||
template<typename _CharT, typename _Traits>
|
||||
class ostreambuf_iterator
|
||||
: public iterator<output_iterator_tag, _CharT, void, void, void>
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
|
|
|
@ -41,11 +41,10 @@
|
|||
|
||||
#include <bits/c++config.h>
|
||||
#include <bits/std_cmath.h>
|
||||
#include <bits/std_iosfwd.h>
|
||||
#include <bits/std_sstream.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
template<typename _Tp> class complex;
|
||||
template<> class complex<float>;
|
||||
|
@ -346,11 +345,47 @@ namespace std
|
|||
|
||||
template<typename _Tp, typename _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>&, complex<_Tp>&);
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
|
||||
{
|
||||
_Tp __re_x, __im_x;
|
||||
_CharT __ch;
|
||||
__is >> __ch;
|
||||
if (__ch == '(')
|
||||
{
|
||||
__is >> __re_x >> __ch;
|
||||
if (__ch == ',')
|
||||
{
|
||||
__is >> __im_x >> __ch;
|
||||
if (__ch == ')')
|
||||
__x = complex<_Tp>(__re_x, __im_x);
|
||||
else
|
||||
__is.setstate(ios_base::failbit);
|
||||
}
|
||||
else if (__ch == ')')
|
||||
__x = complex<_Tp>(__re_x, _Tp(0));
|
||||
else
|
||||
__is.setstate(ios_base::failbit);
|
||||
}
|
||||
else
|
||||
{
|
||||
__is.putback(__ch);
|
||||
__is >> __re_x;
|
||||
__x = complex<_Tp>(__re_x, _Tp(0));
|
||||
}
|
||||
return __is;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>&, const complex<_Tp>&);
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
|
||||
{
|
||||
basic_ostringstream<_CharT, _Traits> __s;
|
||||
__s.flags(__os.flags());
|
||||
__s.imbue(__os.getloc());
|
||||
__s.precision(__os.precision());
|
||||
__s << '(' << __x.real() << "," << __x.imag() << ')';
|
||||
return __os << __s.str();
|
||||
}
|
||||
|
||||
// Values
|
||||
template<typename _Tp>
|
||||
|
|
|
@ -129,3 +129,8 @@ namespace std
|
|||
} // namespace std
|
||||
|
||||
#endif // _CPP_IOSFWD
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
namespace std
|
||||
{
|
||||
|
||||
// 27.6.1.1 Template class basic_istream
|
||||
template<typename _CharT, typename _Traits>
|
||||
class basic_istream : virtual public basic_ios<_CharT, _Traits>
|
||||
|
@ -59,7 +58,7 @@ namespace std
|
|||
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
|
||||
typedef basic_ios<_CharT, _Traits> __ios_type;
|
||||
typedef basic_istream<_CharT, _Traits> __istream_type;
|
||||
typedef istreambuf_iterator<_CharT> __istreambuf_iter;
|
||||
typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
|
||||
typedef num_get<_CharT, __istreambuf_iter> __numget_type;
|
||||
typedef ctype<_CharT> __ctype_type;
|
||||
|
||||
|
@ -78,10 +77,7 @@ namespace std
|
|||
|
||||
virtual
|
||||
~basic_istream()
|
||||
{
|
||||
_M_gcount = streamsize(0);
|
||||
_M_fnumget = NULL;
|
||||
}
|
||||
{ _M_gcount = streamsize(0); }
|
||||
|
||||
// 27.6.1.1.2 Prefix/suffix:
|
||||
class sentry;
|
||||
|
@ -289,7 +285,6 @@ namespace std
|
|||
template<typename _CharT, typename _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
ws(basic_istream<_CharT, _Traits>& __is);
|
||||
|
||||
} // namespace std
|
||||
|
||||
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace std
|
|||
typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
|
||||
typedef basic_ios<_CharT, _Traits> __ios_type;
|
||||
typedef basic_ostream<_CharT, _Traits> __ostream_type;
|
||||
typedef ostreambuf_iterator<_CharT> __ostreambuf_iter;
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
|
||||
typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
|
||||
typedef ctype<_CharT> __ctype_type;
|
||||
|
||||
|
@ -67,8 +67,7 @@ namespace std
|
|||
{ this->init(__sb); }
|
||||
|
||||
virtual
|
||||
~basic_ostream()
|
||||
{ _M_fnumput = NULL; }
|
||||
~basic_ostream() { }
|
||||
|
||||
// 27.6.2.3 Prefix/suffix:
|
||||
class sentry;
|
||||
|
|
|
@ -277,7 +277,6 @@ namespace std
|
|||
_M_buf_size_opt = 0;
|
||||
_M_mode = ios_base::openmode(0);
|
||||
_M_buf_locale_init = false;
|
||||
|
||||
}
|
||||
|
||||
// Locales:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// The template and inlines for the -*- C++ -*- complex number classes.
|
||||
|
||||
// Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2000, 2001 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
|
||||
|
@ -28,66 +28,9 @@
|
|||
// the GNU General Public License.
|
||||
|
||||
#include <bits/std_complex.h>
|
||||
#include <bits/std_istream.h>
|
||||
#include <bits/std_ostream.h>
|
||||
#include <bits/std_sstream.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template<typename _Tp, typename _CharT, class _Traits>
|
||||
basic_istream <_CharT, _Traits> &
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
|
||||
{
|
||||
#if !defined(_GLIBCPP_BUGGY_FLOAT_COMPLEX) && !defined(_GLIBCPP_BUGGY_COMPLEX)
|
||||
_Tp __re_x, __im_x;
|
||||
_CharT __ch;
|
||||
__is >> __ch;
|
||||
if (__ch == '(')
|
||||
{
|
||||
__is >> __re_x >> __ch;
|
||||
if (__ch == ',')
|
||||
{
|
||||
__is >> __im_x >> __ch;
|
||||
if (__ch == ')')
|
||||
{
|
||||
__x = complex<_Tp>(__re_x, __im_x);
|
||||
return __is;
|
||||
}
|
||||
}
|
||||
else if (__ch == ')')
|
||||
{
|
||||
__x = complex<_Tp>(__re_x, _Tp(0));
|
||||
return __is;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__is.putback(__ch);
|
||||
__is >> __re_x;
|
||||
__x = complex<_Tp>(__re_x, _Tp(0));
|
||||
return __is;
|
||||
}
|
||||
__is.setstate(ios_base::failbit);
|
||||
#else
|
||||
__x = complex<_Tp>(_Tp(0), _Tp(0));
|
||||
#endif
|
||||
return __is;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
|
||||
{
|
||||
basic_ostringstream<_CharT, _Traits> __s;
|
||||
__s.flags(__os.flags());
|
||||
__s.imbue(__os.getloc());
|
||||
__s.precision (__os.precision());
|
||||
__s << '(' << __x.real() << "," << __x.imag() << ')' << ends;
|
||||
return __os << __s.str();
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
basic_istream<char, char_traits<char> >&
|
||||
operator>>(basic_istream<char, char_traits<char> >&, complex<float>&);
|
||||
|
@ -149,3 +92,5 @@ namespace std
|
|||
#endif //_GLIBCPP_USE_WCHAR_T
|
||||
} // namespace std
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -170,11 +170,30 @@ namespace std
|
|||
// has_facet
|
||||
template
|
||||
bool
|
||||
has_facet<numpunct<char> >(const locale &);
|
||||
has_facet<numpunct<char> >(const locale&);
|
||||
template
|
||||
bool
|
||||
has_facet<num_put<char> >(const locale&);
|
||||
template
|
||||
bool
|
||||
has_facet<num_get<char> >(const locale&);
|
||||
template
|
||||
bool
|
||||
has_facet<ctype<char> >(const locale&);
|
||||
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
template
|
||||
bool
|
||||
has_facet<numpunct<wchar_t> >(const locale &);
|
||||
has_facet<numpunct<wchar_t> >(const locale&);
|
||||
template
|
||||
bool
|
||||
has_facet<num_put<wchar_t> >(const locale&);
|
||||
template
|
||||
bool
|
||||
has_facet<num_get<wchar_t> >(const locale&);
|
||||
template
|
||||
bool
|
||||
has_facet<ctype<wchar_t> >(const locale&);
|
||||
#endif
|
||||
|
||||
//
|
||||
|
|
|
@ -88,11 +88,58 @@ testall()
|
|||
return 0;
|
||||
}
|
||||
|
||||
// libstdc++/2970
|
||||
void test01()
|
||||
{
|
||||
using namespace std;
|
||||
bool test = true;
|
||||
|
||||
complex<float> cf01(-1.1, -333.2);
|
||||
stringstream ss;
|
||||
ss << cf01;
|
||||
string str = ss.str();
|
||||
VERIFY( str == "(-1.1,-333.2)" );
|
||||
}
|
||||
|
||||
// libstdc++/2985
|
||||
struct gnu_char_traits : public std::char_traits<char>
|
||||
{ };
|
||||
|
||||
typedef std::basic_ostringstream<char, gnu_char_traits> gnu_sstream;
|
||||
|
||||
void test02()
|
||||
{
|
||||
bool test = true;
|
||||
|
||||
// Construct locale with specialized facets.
|
||||
typedef gnu_sstream::__numput_type numput_type;
|
||||
typedef gnu_sstream::__numget_type numget_type;
|
||||
std::locale loc_c = std::locale::classic();
|
||||
std::locale loc_1(loc_c, new numput_type);
|
||||
std::locale loc_2(loc_1, new numget_type);
|
||||
VERIFY( std::has_facet<numput_type>(loc_2) );
|
||||
VERIFY( std::has_facet<numget_type>(loc_2) );
|
||||
|
||||
gnu_sstream sstr;
|
||||
std::basic_ios<char, gnu_char_traits>* pios = &sstr;
|
||||
sstr.imbue(loc_2);
|
||||
|
||||
|
||||
std::complex<double> x(3, 4);
|
||||
sstr << x;
|
||||
VERIFY( sstr.str() == "(3,4)" );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
testall<float>();
|
||||
testall<double>();
|
||||
testall<long double>();
|
||||
|
||||
test01();
|
||||
test02();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue