Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/flyweight/detail/perfect_fwd.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 /* Copyright 2006-2008 Joaquin M Lopez Munoz. | 1 /* Copyright 2006-2014 Joaquin M Lopez Munoz. |
2 * Distributed under the Boost Software License, Version 1.0. | 2 * Distributed under the Boost Software License, Version 1.0. |
3 * (See accompanying file LICENSE_1_0.txt or copy at | 3 * (See accompanying file LICENSE_1_0.txt or copy at |
4 * http://www.boost.org/LICENSE_1_0.txt) | 4 * http://www.boost.org/LICENSE_1_0.txt) |
5 * | 5 * |
6 * See http://www.boost.org/libs/flyweight for library home page. | 6 * See http://www.boost.org/libs/flyweight for library home page. |
7 */ | 7 */ |
8 | 8 |
9 /* Brute force implementation of perfect forwarding overloads. | 9 #ifndef BOOST_FLYWEIGHT_DETAIL_PERFECT_FWD_HPP |
10 * Usage: include after having defined the argument macros: | 10 #define BOOST_FLYWEIGHT_DETAIL_PERFECT_FWD_HPP |
11 * BOOST_FLYWEIGHT_PERFECT_FWD_NAME | 11 |
12 * BOOST_FLYWEIGHT_PERFECT_FWD_BODY | 12 #if defined(_MSC_VER) |
13 #pragma once | |
14 #endif | |
15 | |
16 /* C++03-compatible implementation of perfect forwarding. | |
17 * Usage: | |
18 * | |
19 * # define NAME ... | |
20 * # define BODY(args) {...BOOST_FLYWEIGHT_FORWARD(args)...} | |
21 * BOOST_FLYWEIGHT_PERFECT_FWD(name,body) | |
22 * | |
23 * where NAME includes the return type and qualifiers (if any) and BODY(args) | |
24 * is expected to fo the forwarding through BOOST_FLYWEIGHT_FORWARD(args). | |
25 * | |
26 * In compilers capable of perfect forwarding, the real thing is provided | |
27 * (just one variadic args overload is generated). Otherwise the machinery | |
28 * generates n+1 overloads, if rvalue refs are supported, or else 2^(n+1)-1 | |
29 * overloads accepting any combination of lvalue refs and const lvalue refs, | |
30 * up to BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS args. | |
31 * | |
32 * BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) is a variation omitting the | |
33 * overloads with zero args --when perfect forwarding is available, this second | |
34 * macro is exactly the same as the original. | |
13 */ | 35 */ |
14 | 36 |
15 /* This user_definable macro limits the maximum number of arguments to | 37 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ |
16 * be perfect forwarded. Beware combinatorial explosion: manual perfect | 38 #include <boost/preprocessor/cat.hpp> |
17 * forwarding for n arguments produces 2^n distinct overloads. | 39 #include <boost/preprocessor/repetition/enum.hpp> |
18 */ | 40 #include <boost/preprocessor/repetition/enum_params.hpp> |
41 #include <boost/preprocessor/seq/seq.hpp> | |
42 | |
43 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | |
44 #include <utility> | |
45 #endif | |
46 | |
47 #define BOOST_FLYWEIGHT_FORWARD_FORWARD_AUX(z,n,_) \ | |
48 std::forward<BOOST_PP_CAT(T,n)>(BOOST_PP_CAT(t,n)) | |
49 | |
50 #define BOOST_FLYWEIGHT_FORWARD_FORWARD(n) \ | |
51 BOOST_PP_ENUM(n,BOOST_FLYWEIGHT_FORWARD_FORWARD_AUX,~) | |
52 | |
53 #define BOOST_FLYWEIGHT_FORWARD_ENUM(n) BOOST_PP_ENUM_PARAMS(n,t) | |
54 | |
55 #define BOOST_FLYWEIGHT_FORWARD_PASS(arg) arg | |
56 | |
57 #define BOOST_FLYWEIGHT_FORWARD(args)\ | |
58 BOOST_PP_CAT(BOOST_FLYWEIGHT_FORWARD_,BOOST_PP_SEQ_HEAD(args))( \ | |
59 BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(args))) | |
60 | |
61 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)||\ | |
62 defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
19 | 63 |
20 #if !defined(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS) | 64 #if !defined(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS) |
21 #define BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS 5 | 65 #define BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS 5 |
66 #endif | |
67 | |
68 #if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS<0 | |
69 #error BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS must be >=0 | |
22 #endif | 70 #endif |
23 | 71 |
24 #if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS<=5 | 72 #if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS<=5 |
25 #include <boost/flyweight/detail/pp_perfect_fwd.hpp> | 73 #include <boost/flyweight/detail/pp_perfect_fwd.hpp> |
26 #else | 74 #else |
27 #include <boost/flyweight/detail/dyn_perfect_fwd.hpp> | 75 #include <boost/flyweight/detail/dyn_perfect_fwd.hpp> |
28 #endif | 76 #endif |
77 | |
78 #else | |
79 | |
80 /* real perfect forwarding */ | |
81 | |
82 #define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \ | |
83 template<typename... Args>name(Args&&... args) \ | |
84 body((PASS)(std::forward<Args>(args)...)) | |
85 | |
86 #define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS \ | |
87 BOOST_FLYWEIGHT_PERFECT_FWD | |
88 | |
89 #endif | |
90 #endif |