Chris@16: // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) Chris@16: // (C) Copyright 2003-2007 Jonathan Turkanis Chris@16: // Distributed under 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/iostreams for documentation. Chris@16: Chris@16: #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED Chris@16: #define BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include // BOOST_MSVC, BOOST_NO_SFINAE Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: //------Macros for defining forwarding constructors and open overloads--------// Chris@16: Chris@16: // Chris@16: // Macro: BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args) Chris@16: // Description: Defines constructors and overloads of 'open' which construct Chris@16: // a device using the specified argument list and pass it to the specified Chris@16: // helper function Chris@16: // class - The class name Chris@16: // impl - The helper function Chris@16: // device - The device type Chris@16: // params - The list of formal parameters trailing the device parameter in Chris@16: // the helper function's signature Chris@16: // params - The list of arguments passed to the helper function, following the Chris@16: // device argument Chris@16: // Chris@16: #define BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args) \ Chris@16: class(const device& t params()) \ Chris@16: { this->impl(::boost::iostreams::detail::wrap(t) args()); } \ Chris@16: class(device& t params()) \ Chris@16: { this->impl(::boost::iostreams::detail::wrap(t) args()); } \ Chris@16: class(const ::boost::reference_wrapper& ref params()) \ Chris@16: { this->impl(ref args()); } \ Chris@16: void open(const device& t params()) \ Chris@16: { this->impl(::boost::iostreams::detail::wrap(t) args()); } \ Chris@16: void open(device& t params()) \ Chris@16: { this->impl(::boost::iostreams::detail::wrap(t) args()); } \ Chris@16: void open(const ::boost::reference_wrapper& ref params()) \ Chris@16: { this->impl(ref args()); } \ Chris@16: BOOST_PP_REPEAT_FROM_TO( \ Chris@16: 1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \ Chris@16: BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, device) \ Chris@16: ) \ Chris@16: BOOST_PP_REPEAT_FROM_TO( \ Chris@16: 1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \ Chris@16: BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, device) \ Chris@16: ) \ Chris@16: /**/ Chris@16: #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) Chris@16: # define BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \ Chris@16: template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \ Chris@16: BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \ Chris@16: BOOST_PP_TUPLE_ELEM(3, 0, tuple) \ Chris@16: ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \ Chris@16: BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \ Chris@16: BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \ Chris@16: { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \ Chris@16: ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \ Chris@16: ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \ Chris@16: BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u)) ); } \ Chris@16: /**/ Chris@16: # define BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \ Chris@16: template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \ Chris@16: BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \ Chris@16: void open \ Chris@16: ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \ Chris@16: BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \ Chris@16: BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \ Chris@16: { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \ Chris@16: ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \ Chris@16: BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u) ); } \ Chris@16: /**/ Chris@16: #else Chris@16: # define BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) Chris@16: # define BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) Chris@16: #endif Chris@16: #define BOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \ Chris@16: template \ Chris@16: BOOST_PP_TUPLE_ELEM(3, 0, tuple) \ Chris@16: (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \ Chris@16: BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \ Chris@16: { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \ Chris@16: ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \ Chris@16: (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \ Chris@16: BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \ Chris@16: /**/ Chris@16: #define BOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \ Chris@16: template \ Chris@16: void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \ Chris@16: BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \ Chris@16: { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \ Chris@16: ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \ Chris@16: (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \ Chris@16: BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \ Chris@16: /**/ Chris@16: Chris@16: // Disable forwarding constructors if first parameter type is the same Chris@16: // as the device type Chris@16: #if !defined(BOOST_NO_SFINAE) && \ Chris@16: !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) Chris@16: # define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) \ Chris@16: , typename boost::disable_if< boost::is_same >::type* = 0 \ Chris@16: /**/ Chris@16: #else Chris@16: # define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) Chris@16: #endif Chris@16: Chris@16: #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED