Chris@16: // ---------------------------------------------------------------------------- Chris@16: // compat_workarounds : general framework for non-conformance workarounds Chris@16: // ---------------------------------------------------------------------------- Chris@16: Chris@16: // Copyright Samuel Krempp 2003. Use, modification, and distribution are Chris@16: // subject to the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // see http://www.boost.org/libs/format for library home page Chris@16: Chris@16: // ---------------------------------------------------------------------------- Chris@16: Chris@16: Chris@16: // this file defines wrapper classes to hide non-conforming Chris@16: // std::char_traits<> and std::allocator<> traits Chris@16: // and Includes : config_macros.hpp (defines config macros Chris@16: // and compiler-specific switches) Chris@16: Chris@16: // Non-conformant Std-libs fail to supply conformant traits (std::char_traits, Chris@16: // std::allocator) and/or the std::string doesnt support them. Chris@16: // We don't want to have hundreds of #ifdef workarounds, so we define Chris@16: // replacement traits. Chris@16: // But both char_traits and allocator traits are visible in the interface, Chris@16: // (inside the final string type), thus we need to keep both Chris@16: // the replacement type (typedefed to 'compatible_type') for real use, Chris@16: // and the original stdlib type (typedef to 'type_for_string') for interface Chris@16: // visibility. This is what Compat* classes do (as well as be transparent Chris@16: // when good allocator and char traits are present) Chris@16: Chris@16: #ifndef BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP Chris@16: #define BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP Chris@16: Chris@16: namespace boost { Chris@16: namespace io { Chris@16: Chris@16: // gcc-2.95 char traits (non-conformantly named string_char_traits) Chris@16: // lack several functions so we extend them in a replacement class. Chris@16: template Chris@16: class CompatTraits; Chris@16: Chris@16: // std::allocator in gcc-2.95 is ok, but basic_string only works Chris@16: // with plain 'std::alloc' still, alt_stringbuf requires a functionnal Chris@16: // alloc template argument, so we need a replacement allocator Chris@16: template Chris@16: class CompatAlloc; Chris@16: } // N.S. io Chris@16: }// N.S. boost Chris@16: Chris@16: Chris@16: #include Chris@16: // sets-up macros and load compiler-specific workarounds headers. Chris@16: Chris@16: #if !defined(BOOST_FORMAT_STREAMBUF_DEFINED) Chris@16: // workarounds-gcc-2.95 might have defined own streambuf Chris@16: #include Chris@16: #endif Chris@16: Chris@16: #if !defined(BOOST_FORMAT_OSTREAM_DEFINED) Chris@16: // workarounds-gcc-2.95 might already have included Chris@16: #include Chris@16: #endif Chris@16: Chris@16: Chris@16: Chris@16: namespace boost { Chris@16: namespace io { Chris@16: Chris@16: // **** CompatTraits general definitions : ---------------------------- Chris@16: template Chris@16: class CompatTraits Chris@16: { // general case : be transparent Chris@16: public: Chris@16: typedef Tr compatible_type; Chris@16: }; Chris@16: Chris@16: // **** CompatAlloc general definitions : ----------------------------- Chris@16: template Chris@16: class CompatAlloc Chris@16: { // general case : be transparent Chris@16: public: Chris@16: typedef Alloc compatible_type; Chris@16: }; Chris@16: Chris@16: } //N.S. io Chris@16: } // N.S. boost Chris@16: #endif // include guard