diff options
Diffstat (limited to 'libstdc++-v3/include/bits/basic_ios.tcc')
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.tcc | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 4db4a82d5ac..7ee8015e29f 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -64,31 +64,31 @@ namespace std // associated with imbue() // Alloc any new word array first, so if it fails we have "rollback". - _Words* __words = (__rhs._M_word_limit <= _S_local_words) ? - _M_word_array : new _Words[__rhs._M_word_limit]; - - // XXX This is the only reason _Callback_list was defined - // inline. The suspicion is that this increased compilation - // times dramatically for functions that use this member - // function (inserters_extractors, ios_manip_fmtflags). FIX ME, - // clean this stuff up. Callbacks are broken right now, anyway. + _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? + _M_local_word : new _Words[__rhs._M_word_size]; // Bump refs before doing callbacks, for safety. _Callback_list* __cb = __rhs._M_callbacks; if (__cb) __cb->_M_add_reference(); _M_call_callbacks(erase_event); - if (_M_words != _M_word_array) - delete [] _M_words; + if (_M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } _M_dispose_callbacks(); _M_callbacks = __cb; // NB: Don't want any added during above. - for (int __i = 0; __i < __rhs._M_word_limit; ++__i) - __words[__i] = __rhs._M_words[__i]; - if (_M_words != _M_word_array) - delete [] _M_words; - _M_words = __words; - _M_word_limit = __rhs._M_word_limit; + for (int __i = 0; __i < __rhs._M_word_size; ++__i) + __words[__i] = __rhs._M_word[__i]; + if (_M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } + _M_word = __words; + _M_word_size = __rhs._M_word_size; this->flags(__rhs.flags()); this->width(__rhs.width()); @@ -107,8 +107,8 @@ namespace std basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const { char __ret = __dfault; - if (_M_check_facet(_M_ios_fctype)) - __ret = _M_ios_fctype->narrow(__c, __dfault); + if (_M_check_facet(_M_fctype)) + __ret = _M_fctype->narrow(__c, __dfault); return __ret; } @@ -117,8 +117,8 @@ namespace std basic_ios<_CharT, _Traits>::widen(char __c) const { char_type __ret = char_type(); - if (_M_check_facet(_M_ios_fctype)) - __ret = _M_ios_fctype->widen(__c); + if (_M_check_facet(_M_fctype)) + __ret = _M_fctype->widen(__c); return __ret; } @@ -144,17 +144,20 @@ namespace std _M_cache_facets(_M_ios_locale); _M_tie = 0; - // NB: The 27.4.4.1 Postconditions Table only specifies - // requirements after basic_ios::init() has been called. As part - // of this, fill() must return widen(' '), which needs an imbued - // ctype facet of char_type to return without throwing an - // exception. This is not a required facet, so streams with - // char_type != [char, wchar_t] will not have it by - // default. However, because fill()'s signature is const, this - // data member cannot be lazily initialized. Thus, thoughts of - // using a non-const helper function in ostream inserters is - // really besides the point. - _M_fill = this->widen(' '); + // NB: The 27.4.4.1 Postconditions Table specifies requirements + // after basic_ios::init() has been called. As part of this, + // fill() must return widen(' ') any time after init() has been + // called, which needs an imbued ctype facet of char_type to + // return without throwing an exception. Unfortunately, + // ctype<char_type> is not necessarily a required facet, so + // streams with char_type != [char, wchar_t] will not have it by + // default. Because of this, the correct value for _M_fill is + // constructed on the first call of fill(). That way, + // unformatted input and output with non-required basic_ios + // instantiations is possible even without imbuing the expected + // ctype<char_type> facet. + _M_fill = _CharT(); + _M_fill_init = false; _M_exception = goodbit; _M_streambuf = __sb; @@ -166,9 +169,9 @@ namespace std basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc) { if (has_facet<__ctype_type>(__loc)) - _M_ios_fctype = &use_facet<__ctype_type>(__loc); + _M_fctype = &use_facet<__ctype_type>(__loc); else - _M_ios_fctype = 0; + _M_fctype = 0; // Should be filled in by ostream and istream, respectively. if (has_facet<__numput_type>(__loc)) _M_fnumput = &use_facet<__numput_type>(__loc); @@ -184,7 +187,10 @@ namespace std // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. extern template class basic_ios<char>; + +#ifdef _GLIBCPP_USE_WCHAR_T extern template class basic_ios<wchar_t>; +#endif } // namespace std #endif |