// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) // (C) Copyright 2003-2007 Jonathan Turkanis // Distributed under 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/iostreams for documentation. #ifndef BOOST_IOSTREAMS_DETAIL_RESOLVE_HPP_INCLUDED #define BOOST_IOSTREAMS_DETAIL_RESOLVE_HPP_INCLUDED #if defined(_MSC_VER) # pragma once #endif #include // partial spec, put size_t in std. #include // std::size_t. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // true_. #include #include #include // Must come last. #include // VC7.1 C4224. namespace boost { namespace iostreams { namespace detail { //------------------Definition of resolve-------------------------------------// #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //-------------------------// template struct resolve_traits { typedef typename mpl::if_< boost::detail::is_incrementable, output_iterator_adapter, const T& >::type type; }; # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------------------// template typename resolve_traits::type resolve( const T& t BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) // I suspect that the compilers which require this workaround may // be correct, but I'm not sure why :( #if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, BOOST_TESTED_AT(810)) ||\ BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) || \ BOOST_WORKAROUND(BOOST_IOSTREAMS_GCC, BOOST_TESTED_AT(400)) ||\ BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(1110)) /**/ , typename disable_if< is_iterator_range >::type* = 0 #endif ) { typedef typename resolve_traits::type return_type; return return_type(t); } template mode_adapter< Mode, std::basic_streambuf > resolve(std::basic_streambuf& sb) { return mode_adapter< Mode, std::basic_streambuf >(wrap(sb)); } template mode_adapter< Mode, std::basic_istream > resolve(std::basic_istream& is) { return mode_adapter< Mode, std::basic_istream >(wrap(is)); } template mode_adapter< Mode, std::basic_ostream > resolve(std::basic_ostream& os) { return mode_adapter< Mode, std::basic_ostream >(wrap(os)); } template mode_adapter< Mode, std::basic_iostream > resolve(std::basic_iostream& io) { return mode_adapter< Mode, std::basic_iostream >(wrap(io)); } template array_adapter resolve(Ch (&array)[N]) { return array_adapter(array); } template range_adapter< Mode, boost::iterator_range > resolve(const boost::iterator_range& rng) { return range_adapter< Mode, boost::iterator_range >(rng); } # else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //---------------------// template typename resolve_traits::type resolve( const T& t BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) #if defined(__GNUC__) , typename disable_if< is_iterator_range >::type* = 0 #endif ) { typedef typename resolve_traits::type return_type; return return_type(t); } template mode_adapter resolve(std::streambuf& sb) { return mode_adapter(wrap(sb)); } template mode_adapter resolve(std::istream& is) { return mode_adapter(wrap(is)); } template mode_adapter resolve(std::ostream& os) { return mode_adapter(wrap(os)); } template mode_adapter resolve(std::iostream& io) { return mode_adapter(wrap(io)); } template array_adapter resolve(Ch (&array)[N]) { return array_adapter(array); } template range_adapter< Mode, boost::iterator_range > resolve(const boost::iterator_range& rng) { return range_adapter< Mode, boost::iterator_range >(rng); } # endif // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------// #else // #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //----------------// template struct resolve_traits { // Note: test for is_iterator_range must come before test for output // iterator. typedef typename iostreams::select< // Disambiguation for Tru64. is_std_io, mode_adapter, is_iterator_range, range_adapter, is_dereferenceable, output_iterator_adapter, is_array, array_adapter, else_, #if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) const T& #else T #endif >::type type; }; template typename resolve_traits::type resolve(const T& t, mpl::true_) { // Bad overload resolution. typedef typename resolve_traits::type return_type; return return_type(wrap(const_cast(t))); } template typename resolve_traits::type resolve(const T& t, mpl::false_) { typedef typename resolve_traits::type return_type; return return_type(t); } template typename resolve_traits::type resolve(const T& t BOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) { return resolve(t, is_std_io()); } # if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) && \ !defined(__GNUC__) // ---------------------------------------------------// template typename resolve_traits::type resolve(T& t, mpl::true_) { typedef typename resolve_traits::type return_type; return return_type(wrap(t)); } template typename resolve_traits::type resolve(T& t, mpl::false_) { typedef typename resolve_traits::type return_type; return return_type(t); } template typename resolve_traits::type resolve(T& t BOOST_IOSTREAMS_ENABLE_IF_STREAM(T)) { return resolve(t, is_std_io()); } # endif // Borland 5.x or GCC //--------------------------------// #endif // #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //---------------// } } } // End namespaces detail, iostreams, boost. #include // VC7.1 4224. #endif // BOOST_IOSTREAMS_DETAIL_RESOLVE_HPP_INCLUDED