]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/flyweight/include/boost/flyweight/detail/dyn_perfect_fwd.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / flyweight / include / boost / flyweight / detail / dyn_perfect_fwd.hpp
1 /* Copyright 2006-2014 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 *
6 * See http://www.boost.org/libs/flyweight for library home page.
7 */
8
9 #ifndef BOOST_FLYWEIGHT_DETAIL_DYN_PERFECT_FWD_HPP
10 #define BOOST_FLYWEIGHT_DETAIL_DYN_PERFECT_FWD_HPP
11
12 #if defined(_MSC_VER)
13 #pragma once
14 #endif
15
16 #include <boost/config.hpp>
17
18 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
19
20 #include <boost/preprocessor/arithmetic/add.hpp>
21 #include <boost/preprocessor/cat.hpp>
22 #include <boost/preprocessor/repetition/enum.hpp>
23 #include <boost/preprocessor/repetition/enum_params.hpp>
24 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
25 #include <boost/preprocessor/seq/seq.hpp>
26
27 #define BOOST_FLYWEIGHT_PERFECT_FWD_ARG(z,n,_) \
28 BOOST_PP_CAT(T,n)&& BOOST_PP_CAT(t,n)
29
30 #define BOOST_FLYWEIGHT_PERFECT_FWD_N_AUX(n,name,body) \
31 template<BOOST_PP_ENUM_PARAMS(n,typename T)> \
32 name(BOOST_PP_ENUM(n,BOOST_FLYWEIGHT_PERFECT_FWD_ARG,~)) \
33 body((FORWARD)(n))
34
35 #define BOOST_FLYWEIGHT_PERFECT_FWD_N(z,n,data) \
36 BOOST_FLYWEIGHT_PERFECT_FWD_N_AUX( \
37 n,BOOST_PP_SEQ_HEAD(data), \
38 BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(data)))
39
40 #define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
41 BOOST_PP_REPEAT_FROM_TO( \
42 1,BOOST_PP_ADD(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS,1), \
43 BOOST_FLYWEIGHT_PERFECT_FWD_N,(name)(body))
44
45 #define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \
46 name()body((ENUM)(0)) \
47 BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body)
48
49 #else
50
51 /* no rvalue refs -> [const] Tn& overloads */
52
53 #include <boost/preprocessor/arithmetic/add.hpp>
54 #include <boost/preprocessor/cat.hpp>
55 #include <boost/preprocessor/repetition/enum.hpp>
56 #include <boost/preprocessor/repetition/enum_params.hpp>
57 #include <boost/preprocessor/repetition/repeat.hpp>
58 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
59 #include <boost/preprocessor/seq/elem.hpp>
60 #include <boost/preprocessor/seq/for_each_product.hpp>
61 #include <boost/preprocessor/seq/seq.hpp>
62 #include <boost/preprocessor/seq/size.hpp>
63
64 #define BOOST_FLYWEIGHT_CONST(b) BOOST_PP_CAT(BOOST_FLYWEIGHT_CONST,b)
65 #define BOOST_FLYWEIGHT_CONST0
66 #define BOOST_FLYWEIGHT_CONST1 const
67
68 /* if mask[n]==0 --> Tn& tn
69 * if mask[n]==1 --> const Tn& tn
70 */
71
72 #define BOOST_FLYWEIGHT_PERFECT_FWD_ARG(z,n,mask) \
73 BOOST_FLYWEIGHT_CONST(BOOST_PP_SEQ_ELEM(n,mask)) \
74 BOOST_PP_CAT(T,n)& BOOST_PP_CAT(t,n)
75
76 /* overload accepting size(mask) args, where the template args are
77 * marked const or not according to the given mask (a seq of 0 or 1)
78 */
79
80 #define BOOST_FLYWEIGHT_PERFECT_FWD_MASK_AUX(r,name,body,mask) \
81 template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(mask),typename T)> \
82 name( \
83 BOOST_PP_ENUM( \
84 BOOST_PP_SEQ_SIZE(mask),BOOST_FLYWEIGHT_PERFECT_FWD_ARG,mask)) \
85 body((ENUM)(BOOST_PP_SEQ_SIZE(mask)))
86
87 #define BOOST_FLYWEIGHT_PERFECT_FWD_MASK(r,data) \
88 BOOST_FLYWEIGHT_PERFECT_FWD_MASK_AUX( \
89 r, \
90 BOOST_PP_SEQ_ELEM(0,BOOST_PP_SEQ_HEAD(data)), \
91 BOOST_PP_SEQ_ELEM(1,BOOST_PP_SEQ_HEAD(data)), \
92 BOOST_PP_SEQ_TAIL(data))
93
94 #define BOOST_FLYWEIGHT_01(z,n,_) ((0)(1))
95
96 /* Perfect forwarding overloads accepting 1 to n args */
97
98 #define BOOST_FLYWEIGHT_PERFECT_FWD_N(z,n,data) \
99 BOOST_PP_SEQ_FOR_EACH_PRODUCT( \
100 BOOST_FLYWEIGHT_PERFECT_FWD_MASK, \
101 ((data)) \
102 BOOST_PP_REPEAT(n,BOOST_FLYWEIGHT_01,~))
103
104 #define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
105 BOOST_PP_REPEAT_FROM_TO( \
106 1,BOOST_PP_ADD(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS,1), \
107 BOOST_FLYWEIGHT_PERFECT_FWD_N,(name)(body))
108
109 #define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \
110 name()body((ENUM)(0)) \
111 BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body)
112
113 #endif
114 #endif