]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/iostreams/include/boost/iostreams/detail/forward.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / iostreams / include / boost / iostreams / detail / forward.hpp
CommitLineData
7c673cae
FG
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)
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#define BOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \
66 template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
67 BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
68 (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
69 BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
70 { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
71 ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
72 (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
73 template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
74 BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
75 BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
76 ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
77 BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
78 BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
79 { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
80 ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
81 ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
82 BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u)) ); } \
83 /**/
84#define BOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \
85 template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
86 void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
87 BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
88 { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
89 ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
90 (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
91 template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
92 BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
93 void open \
94 ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
95 BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
96 BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
97 { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
98 ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
99 BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u) ); } \
100 /**/
101
102// Disable forwarding constructors if first parameter type is the same
103// as the device type
104#if !defined(BOOST_NO_SFINAE) && \
105 !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
106# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) \
107 , typename boost::disable_if< boost::is_same<device, param> >::type* = 0 \
108 /**/
109#else
110# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param)
111#endif
112
113#endif // #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED