From 9c94af767197f03ee8118822b6b9e23e092ce853 Mon Sep 17 00:00:00 2001 From: Georgiy Guminov Date: Fri, 7 Jun 2024 19:36:18 +0300 Subject: [PATCH 1/5] Remove workaround for gcc 2_95. --- .../format/detail/compat_workarounds.hpp | 29 ---- include/boost/format/detail/config_macros.hpp | 4 +- include/boost/format/detail/unset_macros.hpp | 6 - .../format/detail/workarounds_gcc-2_95.hpp | 162 ------------------ 4 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 include/boost/format/detail/workarounds_gcc-2_95.hpp diff --git a/include/boost/format/detail/compat_workarounds.hpp b/include/boost/format/detail/compat_workarounds.hpp index 8e51514f..2fa09bba 100644 --- a/include/boost/format/detail/compat_workarounds.hpp +++ b/include/boost/format/detail/compat_workarounds.hpp @@ -30,38 +30,9 @@ #ifndef BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP #define BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP -namespace boost { - namespace io { - - // gcc-2.95 char traits (non-conformantly named string_char_traits) - // lack several functions so we extend them in a replacement class. - template - class CompatTraits; - - // std::allocator in gcc-2.95 is ok, but basic_string only works - // with plain 'std::alloc' still, alt_stringbuf requires a functionnal - // alloc template argument, so we need a replacement allocator - template - class CompatAlloc; - } // N.S. io -}// N.S. boost - - #include // sets-up macros and load compiler-specific workarounds headers. -#if !defined(BOOST_FORMAT_STREAMBUF_DEFINED) -// workarounds-gcc-2.95 might have defined own streambuf -#include -#endif - -#if !defined(BOOST_FORMAT_OSTREAM_DEFINED) -// workarounds-gcc-2.95 might already have included -#include -#endif - - - namespace boost { namespace io { diff --git a/include/boost/format/detail/config_macros.hpp b/include/boost/format/detail/config_macros.hpp index 9bd9e6bb..5131cd5b 100644 --- a/include/boost/format/detail/config_macros.hpp +++ b/include/boost/format/detail/config_macros.hpp @@ -23,14 +23,12 @@ // make sure our local macros wont override something : #if defined(BOOST_NO_LOCALE_ISDIGIT) || defined(BOOST_OVERLOAD_FOR_NON_CONST) \ || defined(BOOST_IO_STD) || defined( BOOST_IO_NEEDS_USING_DECLARATION ) \ - || defined(BOOST_NO_TEMPLATE_STD_STREAM) \ - || defined(BOOST_FORMAT_STREAMBUF_DEFINED) || defined(BOOST_FORMAT_OSTREAM_DEFINED) + || defined(BOOST_NO_TEMPLATE_STD_STREAM) #error "boost::format uses a local macro that is already defined." #endif // specific workarounds. each header can define BOOS_IO_STD if it // needs. (e.g. because of IO_NEEDS_USING_DECLARATION) -#include #include #ifndef BOOST_IO_STD diff --git a/include/boost/format/detail/unset_macros.hpp b/include/boost/format/detail/unset_macros.hpp index b3ac47b4..e7aff953 100644 --- a/include/boost/format/detail/unset_macros.hpp +++ b/include/boost/format/detail/unset_macros.hpp @@ -26,9 +26,3 @@ #ifdef BOOST_NO_TEMPLATE_STD_STREAM #undef BOOST_NO_TEMPLATE_STD_STREAM #endif -#ifdef BOOST_FORMAT_STREAMBUF_DEFINED -#undef BOOST_FORMAT_STREAMBUF_DEFINED -#endif -#ifdef BOOST_FORMAT_OSTREAM_DEFINED -#undef BOOST_FORMAT_OSTREAM_DEFINED -#endif diff --git a/include/boost/format/detail/workarounds_gcc-2_95.hpp b/include/boost/format/detail/workarounds_gcc-2_95.hpp deleted file mode 100644 index 8c49d42d..00000000 --- a/include/boost/format/detail/workarounds_gcc-2_95.hpp +++ /dev/null @@ -1,162 +0,0 @@ -// ---------------------------------------------------------------------------- -// workarounds for gcc < 3.0. -// ---------------------------------------------------------------------------- - -// Copyright Samuel Krempp 2003. Use, modification, and distribution are -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/format for library home page - - -// ---------------------------------------------------------------------------- - -// There's a lot to do, the stdlib shipped with gcc prior to 3.x -// was terribly non-conforming. -// . defines macros switches -// . supplies template classes basic_foo where gcc only supplies foo. -// i.e : -// - basic_ios from ios -// - basic_ostream from ostream -// - basic_srteambuf from streambuf -// these can be used transparently. (it obviously does not work for wchar_t) -// . specialise CompatAlloc and CompatTraits to wrap gcc-2.95's -// string_char_traits and std::alloc - -#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) - // only for gcc-2.95's native stdlib - -#ifndef BOOST_FORMAT_WORKAROUNDS_GCC295_H -#define BOOST_FORMAT_WORKAROUNDS_GCC295_H - -// SGI STL doesnt have and others, so we need iostream. -#include -#define BOOST_FORMAT_OSTREAM_DEFINED - -#include -#define BOOST_FORMAT_STREAMBUF_DEFINED - -#define BOOST_NO_TEMPLATE_STD_STREAM - -#ifndef BOOST_IO_STD -# define BOOST_IO_STD std:: -#endif - - - -// *** -// gcc's simple classes turned into standard-like template classes : - -namespace std { - - - // gcc has string_char_traits, it's incomplete. - // we declare a std::char_traits, and specialize CompatTraits<..> on it - // to do what is required - template - class char_traits; // no definition here, we will just use it as a tag. - - template - class basic_streambuf; - - template - class basic_streambuf : public streambuf { - }; - - template > - class basic_ios; - - template - class basic_ios : public ostream { - public: - basic_ios(streambuf * p) : ostream(p) {}; - char fill() const { return ios::fill(); } // gcc returns wchar.. - char fill(char c) { return ios::fill(c); } // gcc takes wchar.. - char widen(char c) { return c; } - char narrow(char c, char def) { return c; } - basic_ios& copyfmt(const ios& right) { - fill(right.fill()); - flags(right.flags() ); - exceptions(right.exceptions()); - width(right.width()); - precision(right.precision()); - return *this; - } - }; - - - typedef ios ios_base; - - template - class basic_ostream; - - template - class basic_ostream : public basic_ios - { - public: - basic_ostream(streambuf * p) : basic_ios (p) {} - }; - -} // namespace std - - -namespace boost { - namespace io { - - - // ** CompatTraits gcc2.95 specialisations ---------------------------- - template - class CompatTraits< ::std::string_char_traits > - : public ::std::string_char_traits - { - public: - typedef CompatTraits compatible_type; - - typedef Ch char_type; - typedef int int_type; - typedef ::std::streampos pos_type; - typedef ::std::streamoff off_type; - - static char_type - to_char_type(const int_type& meta) { - return static_cast(meta); } - static int_type - to_int_type(const char_type& ch) { - return static_cast(static_cast(ch) );} - static bool - eq_int_type(const int_type& left, const int_type& right) { - return left == right; } - static int_type - eof() { - return static_cast(EOF); - } - static int_type - not_eof(const int_type& meta) { - return (meta == eof()) ? 0 : meta; - } - }; - - template - class CompatTraits< ::std::char_traits > { - public: - typedef CompatTraits< ::std::string_char_traits > compatible_type; - }; - - // ** CompatAlloc gcc-2.95 specialisations --------------------------- - template<> - class CompatAlloc< ::std::alloc> - { - public: - typedef ::std::allocator compatible_type; - }; - - } // N.S. io -} // N.S. boost - - - - - -#endif // include guard - -#endif // if workaround From e135169fed5d1081831ba1c97fd458edcb31c56b Mon Sep 17 00:00:00 2001 From: Georgiy Guminov Date: Fri, 7 Jun 2024 20:21:33 +0300 Subject: [PATCH 2/5] Remove workaround for gcc 2_95[2] --- include/boost/format/detail/config_macros.hpp | 3 +-- include/boost/format/detail/unset_macros.hpp | 3 --- include/boost/format/format_class.hpp | 7 ------- include/boost/format/free_funcs.hpp | 15 ++++----------- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/include/boost/format/detail/config_macros.hpp b/include/boost/format/detail/config_macros.hpp index 5131cd5b..db58a53c 100644 --- a/include/boost/format/detail/config_macros.hpp +++ b/include/boost/format/detail/config_macros.hpp @@ -22,8 +22,7 @@ // make sure our local macros wont override something : #if defined(BOOST_NO_LOCALE_ISDIGIT) || defined(BOOST_OVERLOAD_FOR_NON_CONST) \ - || defined(BOOST_IO_STD) || defined( BOOST_IO_NEEDS_USING_DECLARATION ) \ - || defined(BOOST_NO_TEMPLATE_STD_STREAM) + || defined(BOOST_IO_STD) || defined( BOOST_IO_NEEDS_USING_DECLARATION ) #error "boost::format uses a local macro that is already defined." #endif diff --git a/include/boost/format/detail/unset_macros.hpp b/include/boost/format/detail/unset_macros.hpp index e7aff953..5afe7740 100644 --- a/include/boost/format/detail/unset_macros.hpp +++ b/include/boost/format/detail/unset_macros.hpp @@ -23,6 +23,3 @@ #ifdef BOOST_IO_NEEDS_USING_DECLARATION #undef BOOST_IO_NEEDS_USING_DECLARATION #endif -#ifdef BOOST_NO_TEMPLATE_STD_STREAM -#undef BOOST_NO_TEMPLATE_STD_STREAM -#endif diff --git a/include/boost/format/format_class.hpp b/include/boost/format/format_class.hpp index a7ccc29e..e0250a54 100644 --- a/include/boost/format/format_class.hpp +++ b/include/boost/format/format_class.hpp @@ -124,17 +124,10 @@ namespace boost { && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) // use friend templates and private members only if supported -#ifndef BOOST_NO_TEMPLATE_STD_STREAM template friend std::basic_ostream & operator<<( std::basic_ostream & , const basic_format& ); -#else - template - friend std::ostream & - operator<<( std::ostream & , - const basic_format& ); -#endif template friend basic_format& diff --git a/include/boost/format/free_funcs.hpp b/include/boost/format/free_funcs.hpp index 3a515455..b040544f 100644 --- a/include/boost/format/free_funcs.hpp +++ b/include/boost/format/free_funcs.hpp @@ -27,17 +27,10 @@ namespace boost { using ::boost::str; // keep compatibility with when it was defined in this N.S. } // - namespace io -#ifndef BOOST_NO_TEMPLATE_STD_STREAM - template - std::basic_ostream & - operator<<( std::basic_ostream & os, - const basic_format& f) -#else - template - std::ostream & - operator<<( std::ostream & os, - const basic_format& f) -#endif + template + std::basic_ostream & + operator<<( std::basic_ostream & os, + const basic_format& f) // effect: "return os << str(f);" but we can do it faster { typedef boost::basic_format format_t; From e9f2791c27969a7ca9dcc0682be047e2a59e011c Mon Sep 17 00:00:00 2001 From: Georgiy Guminov Date: Fri, 7 Jun 2024 20:52:19 +0300 Subject: [PATCH 3/5] Remove workaround for gcc 2_95[3] --- include/boost/format.hpp | 2 +- include/boost/format/alt_sstream.hpp | 16 +++--- include/boost/format/alt_sstream_impl.hpp | 32 +++++------ .../format/detail/compat_workarounds.hpp | 57 ------------------- include/boost/format/format_class.hpp | 1 - include/boost/format/format_fwd.hpp | 2 +- include/boost/format/internals.hpp | 2 +- 7 files changed, 26 insertions(+), 86 deletions(-) delete mode 100644 include/boost/format/detail/compat_workarounds.hpp diff --git a/include/boost/format.hpp b/include/boost/format.hpp index 0f27a8fb..79d4f2de 100644 --- a/include/boost/format.hpp +++ b/include/boost/format.hpp @@ -24,7 +24,7 @@ #endif // *** Compatibility framework -#include +#include #ifdef BOOST_NO_LOCALE_ISDIGIT #include // we'll use the non-locale 's std::isdigit(int) diff --git a/include/boost/format/alt_sstream.hpp b/include/boost/format/alt_sstream.hpp index 3a0a07a1..cc31cdb0 100644 --- a/include/boost/format/alt_sstream.hpp +++ b/include/boost/format/alt_sstream.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -40,14 +40,12 @@ namespace boost { : public ::std::basic_streambuf { typedef ::std::basic_streambuf streambuf_t; - typedef typename CompatAlloc::compatible_type compat_allocator_type; - typedef typename CompatTraits::compatible_type compat_traits_type; public: typedef Ch char_type; typedef Tr traits_type; - typedef typename compat_traits_type::int_type int_type; - typedef typename compat_traits_type::pos_type pos_type; - typedef typename compat_traits_type::off_type off_type; + typedef typename Tr::int_type int_type; + typedef typename Tr::pos_type pos_type; + typedef typename Tr::off_type off_type; typedef Alloc allocator_type; typedef ::std::basic_string string_type; typedef typename string_type::size_type size_type; @@ -104,8 +102,8 @@ namespace boost { ::std::ios_base::openmode which = ::std::ios_base::in | ::std::ios_base::out); virtual int_type underflow(); - virtual int_type pbackfail(int_type meta = compat_traits_type::eof()); - virtual int_type overflow(int_type meta = compat_traits_type::eof()); + virtual int_type pbackfail(int_type meta = Tr::eof()); + virtual int_type overflow(int_type meta = Tr::eof()); void dealloc(); private: enum { alloc_min = 256}; // minimum size of allocations @@ -113,7 +111,7 @@ namespace boost { Ch *putend_; // remembers (over seeks) the highest value of pptr() bool is_allocated_; ::std::ios_base::openmode mode_; - compat_allocator_type alloc_; // the allocator object + Alloc alloc_; // the allocator object }; diff --git a/include/boost/format/alt_sstream_impl.hpp b/include/boost/format/alt_sstream_impl.hpp index 05379dcb..a55d4932 100644 --- a/include/boost/format/alt_sstream_impl.hpp +++ b/include/boost/format/alt_sstream_impl.hpp @@ -185,19 +185,19 @@ namespace boost { basic_altstringbuf:: underflow () { if(gptr() == NULL) // no get area -> nothing to get. - return (compat_traits_type::eof()); + return (Tr::eof()); else if(gptr() < egptr()) // ok, in buffer - return (compat_traits_type::to_int_type(*gptr())); + return (Tr::to_int_type(*gptr())); else if(mode_ & ::std::ios_base::in && pptr() != NULL && (gptr() < pptr() || gptr() < putend_) ) { // expand get area if(putend_ < pptr()) putend_ = pptr(); // remember pptr reached this far streambuf_t::setg(eback(), gptr(), putend_); - return (compat_traits_type::to_int_type(*gptr())); + return (Tr::to_int_type(*gptr())); } else // couldnt get anything. EOF. - return (compat_traits_type::eof()); + return (Tr::eof()); } // -end underflow(..) @@ -208,16 +208,16 @@ namespace boost { pbackfail (int_type meta) { if(gptr() != NULL && (eback() < gptr()) && (mode_ & (::std::ios_base::out) - || compat_traits_type::eq_int_type(compat_traits_type::eof(), meta) - || compat_traits_type::eq(compat_traits_type::to_char_type(meta), gptr()[-1]) ) ) { + || Tr::eq_int_type(Tr::eof(), meta) + || Tr::eq(Tr::to_char_type(meta), gptr()[-1]) ) ) { streambuf_t::gbump(-1); // back one character - if(!compat_traits_type::eq_int_type(compat_traits_type::eof(), meta)) + if(!Tr::eq_int_type(Tr::eof(), meta)) // put-back meta into get area - *gptr() = compat_traits_type::to_char_type(meta); - return (compat_traits_type::not_eof(meta)); + *gptr() = Tr::to_char_type(meta); + return (Tr::not_eof(meta)); } else - return (compat_traits_type::eof()); // failed putback + return (Tr::eof()); // failed putback } // -end pbackfail(..) @@ -230,15 +230,15 @@ namespace boost { #pragma warning(push) #pragma warning(disable:4996) #endif - if(compat_traits_type::eq_int_type(compat_traits_type::eof(), meta)) - return compat_traits_type::not_eof(meta); // nothing to do + if(Tr::eq_int_type(Tr::eof(), meta)) + return Tr::not_eof(meta); // nothing to do else if(pptr() != NULL && pptr() < epptr()) { - streambuf_t::sputc(compat_traits_type::to_char_type(meta)); + streambuf_t::sputc(Tr::to_char_type(meta)); return meta; } else if(! (mode_ & ::std::ios_base::out)) // no write position, and cant make one - return compat_traits_type::eof(); + return Tr::eof(); else { // make a write position available std::size_t prev_size = pptr() == NULL ? 0 : epptr() - eback(); std::size_t new_size = prev_size; @@ -263,7 +263,7 @@ namespace boost { } if(0 < prev_size) - compat_traits_type::copy(newptr, oldptr, prev_size); + Tr::copy(newptr, oldptr, prev_size); if(is_allocated_) alloc_.deallocate(oldptr, prev_size); is_allocated_=true; @@ -287,7 +287,7 @@ namespace boost { else streambuf_t::setg(newptr, 0, newptr); } - streambuf_t::sputc(compat_traits_type::to_char_type(meta)); + streambuf_t::sputc(Tr::to_char_type(meta)); return meta; } #ifdef BOOST_MSVC diff --git a/include/boost/format/detail/compat_workarounds.hpp b/include/boost/format/detail/compat_workarounds.hpp deleted file mode 100644 index 2fa09bba..00000000 --- a/include/boost/format/detail/compat_workarounds.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// ---------------------------------------------------------------------------- -// compat_workarounds : general framework for non-conformance workarounds -// ---------------------------------------------------------------------------- - -// Copyright Samuel Krempp 2003. Use, modification, and distribution are -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// see http://www.boost.org/libs/format for library home page - -// ---------------------------------------------------------------------------- - - -// this file defines wrapper classes to hide non-conforming -// std::char_traits<> and std::allocator<> traits -// and Includes : config_macros.hpp (defines config macros -// and compiler-specific switches) - -// Non-conformant Std-libs fail to supply conformant traits (std::char_traits, -// std::allocator) and/or the std::string doesnt support them. -// We don't want to have hundreds of #ifdef workarounds, so we define -// replacement traits. -// But both char_traits and allocator traits are visible in the interface, -// (inside the final string type), thus we need to keep both -// the replacement type (typedefed to 'compatible_type') for real use, -// and the original stdlib type (typedef to 'type_for_string') for interface -// visibility. This is what Compat* classes do (as well as be transparent -// when good allocator and char traits are present) - -#ifndef BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP -#define BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP - -#include - // sets-up macros and load compiler-specific workarounds headers. - -namespace boost { - namespace io { - - // **** CompatTraits general definitions : ---------------------------- - template - class CompatTraits - { // general case : be transparent - public: - typedef Tr compatible_type; - }; - - // **** CompatAlloc general definitions : ----------------------------- - template - class CompatAlloc - { // general case : be transparent - public: - typedef Alloc compatible_type; - }; - - } //N.S. io -} // N.S. boost -#endif // include guard diff --git a/include/boost/format/format_class.hpp b/include/boost/format/format_class.hpp index e0250a54..ec771ea4 100644 --- a/include/boost/format/format_class.hpp +++ b/include/boost/format/format_class.hpp @@ -29,7 +29,6 @@ namespace boost { template class basic_format { - typedef typename io::CompatTraits::compatible_type compat_traits; public: typedef Ch CharT; // borland fails in operator% if we use Ch and Tr directly typedef std::basic_string string_type; diff --git a/include/boost/format/format_fwd.hpp b/include/boost/format/format_fwd.hpp index 16b85654..5f7b998b 100644 --- a/include/boost/format/format_fwd.hpp +++ b/include/boost/format/format_fwd.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include namespace boost { diff --git a/include/boost/format/internals.hpp b/include/boost/format/internals.hpp index cd5fc540..997e7ebb 100644 --- a/include/boost/format/internals.hpp +++ b/include/boost/format/internals.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include // used as a dummy stream namespace boost { From bce936124082969a5946c2a1775c6c7b83dbd595 Mon Sep 17 00:00:00 2001 From: Georgiy Guminov Date: Fri, 7 Jun 2024 21:19:57 +0300 Subject: [PATCH 4/5] Return char traits typedef. --- include/boost/format/format_class.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/boost/format/format_class.hpp b/include/boost/format/format_class.hpp index ec771ea4..98498ea6 100644 --- a/include/boost/format/format_class.hpp +++ b/include/boost/format/format_class.hpp @@ -30,7 +30,8 @@ namespace boost { class basic_format { public: - typedef Ch CharT; // borland fails in operator% if we use Ch and Tr directly + typedef Ch CharT; // borland fails in operator% if we use Ch and Tr directly + typedef Tr CharTraitsT; // typedef std::basic_string string_type; typedef typename string_type::size_type size_type; typedef io::detail::format_item format_item_t; @@ -60,34 +61,34 @@ namespace boost { // ** arguments passing ** // template basic_format& operator%(const T& x) - { return io::detail::feed(*this,x); } + { return io::detail::feed(*this,x); } #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST template basic_format& operator%(T& x) - { return io::detail::feed(*this,x); } + { return io::detail::feed(*this,x); } #endif template basic_format& operator%(volatile const T& x) { /* make a non-volatile copy */ const T v(x); - /* pass the copy along */ return io::detail::feed(*this, v); } + /* pass the copy along */ return io::detail::feed(*this, v); } #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST template basic_format& operator%(volatile T& x) { /* make a non-volatile copy */ T v(x); - /* pass the copy along */ return io::detail::feed(*this, v); } + /* pass the copy along */ return io::detail::feed(*this, v); } #endif #if defined(__GNUC__) // GCC can't handle anonymous enums without some help // ** arguments passing ** // basic_format& operator%(const int& x) - { return io::detail::feed(*this,x); } + { return io::detail::feed(*this,x); } #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST basic_format& operator%(int& x) - { return io::detail::feed(*this,x); } + { return io::detail::feed(*this,x); } #endif #endif From c6abfb76396887a4f7e4a125292889d78d6d7c69 Mon Sep 17 00:00:00 2001 From: Georgiy Guminov Date: Fri, 7 Jun 2024 21:52:50 +0300 Subject: [PATCH 5/5] Return some of includes. --- include/boost/format/alt_sstream.hpp | 2 ++ include/boost/format/internals.hpp | 1 + 2 files changed, 3 insertions(+) diff --git a/include/boost/format/alt_sstream.hpp b/include/boost/format/alt_sstream.hpp index cc31cdb0..c1ed2802 100644 --- a/include/boost/format/alt_sstream.hpp +++ b/include/boost/format/alt_sstream.hpp @@ -16,6 +16,8 @@ #define BOOST_SK_ALT_SSTREAM_HPP #include +#include +#include #include #include #include diff --git a/include/boost/format/internals.hpp b/include/boost/format/internals.hpp index 997e7ebb..1289f294 100644 --- a/include/boost/format/internals.hpp +++ b/include/boost/format/internals.hpp @@ -16,6 +16,7 @@ #include +#include #include #include #include