PageRenderTime 22ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/iostreams/detail/forward.hpp

http://hadesmem.googlecode.com/
C++ Header | 124 lines | 89 code | 8 blank | 27 comment | 2 complexity | 4812c3056ef754fbc2e5599501eb1a69 MD5 | raw file
  1// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2// (C) Copyright 2003-2007 Jonathan Turkanis
  3// Distributed under the Boost Software License, Version 1.0. (See accompanying
  4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5
  6// See http://www.boost.org/libs/iostreams for documentation.
  7
  8#ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED
  9#define BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED   
 10
 11#if defined(_MSC_VER) && (_MSC_VER >= 1020)
 12# pragma once
 13#endif                  
 14 
 15#include <boost/config.hpp> // BOOST_MSVC, BOOST_NO_SFINAE
 16#include <boost/detail/workaround.hpp>
 17#include <boost/iostreams/detail/config/limits.hpp>
 18#include <boost/iostreams/detail/push_params.hpp>
 19#include <boost/preprocessor/arithmetic/dec.hpp>
 20#include <boost/preprocessor/arithmetic/inc.hpp>
 21#include <boost/preprocessor/punctuation/comma_if.hpp>
 22#include <boost/preprocessor/repetition/enum_binary_params.hpp>
 23#include <boost/preprocessor/repetition/enum_params.hpp>
 24#include <boost/preprocessor/repetition/repeat_from_to.hpp>
 25#include <boost/preprocessor/tuple/elem.hpp>
 26#include <boost/type_traits/is_same.hpp>
 27
 28//------Macros for defining forwarding constructors and open overloads--------//
 29    
 30//
 31// Macro: BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args)
 32// Description: Defines constructors and overloads of 'open' which construct
 33//      a device using the specified argument list and pass it to the specified
 34//      helper function
 35//   class - The class name
 36//   impl - The helper function
 37//   device - The device type
 38//   params - The list of formal parameters trailing the device parameter in
 39//     the helper function's signature
 40//   params - The list of arguments passed to the helper function, following the
 41//     device argument
 42//
 43#define BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args) \
 44    class(const device& t params()) \
 45    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
 46    class(device& t params()) \
 47    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
 48    class(const ::boost::reference_wrapper<device>& ref params()) \
 49    { this->impl(ref args()); } \
 50    void open(const device& t params()) \
 51    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
 52    void open(device& t params()) \
 53    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
 54    void open(const ::boost::reference_wrapper<device>& ref params()) \
 55    { this->impl(ref args()); } \
 56    BOOST_PP_REPEAT_FROM_TO( \
 57        1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
 58        BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, device) \
 59    ) \
 60    BOOST_PP_REPEAT_FROM_TO( \
 61        1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
 62        BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, device) \
 63    ) \
 64    /**/
 65#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
 66# define BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \
 67    template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
 68              BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
 69    BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
 70    ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
 71      BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
 72      BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
 73    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
 74      ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
 75        ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
 76          BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u)) ); } \
 77    /**/
 78# define BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
 79    template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
 80              BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
 81    void open \
 82    ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
 83      BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
 84      BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
 85    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
 86      ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
 87        BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u) ); } \
 88    /**/
 89#else
 90# define BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple)
 91# define BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple)
 92#endif
 93#define BOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \
 94    template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
 95    BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
 96    (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
 97      BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
 98    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
 99      ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
100        (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
101    BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \
102    /**/
103#define BOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \
104    template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
105    void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
106      BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
107    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
108      ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
109        (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
110    BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
111    /**/
112
113// Disable forwarding constructors if first parameter type is the same
114// as the device type
115#if !defined(BOOST_NO_SFINAE) && \
116    !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
117# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) \
118    , typename boost::disable_if< boost::is_same<device, param> >::type* = 0 \
119    /**/
120#else 
121# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param)
122#endif
123
124#endif // #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED