| 1 | // Copyright Daniel Wallin, David Abrahams 2005. |
| 2 | // Copyright Cromwell D. Enage 2017. |
| 3 | // Distributed under the Boost Software License, Version 1.0. |
| 4 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | // http://www.boost.org/LICENSE_1_0.txt) |
| 6 | |
| 7 | #ifndef BOOST_PARAMETER_AUX_DEFAULT_HPP |
| 8 | #define BOOST_PARAMETER_AUX_DEFAULT_HPP |
| 9 | |
| 10 | namespace boost { namespace parameter { namespace aux { |
| 11 | |
| 12 | // A wrapper for the default value passed by the user when resolving |
| 13 | // the value of the parameter with the given Keyword |
| 14 | template <typename Keyword, typename Value> |
| 15 | struct default_ |
| 16 | { |
| 17 | inline BOOST_CONSTEXPR default_(Value& x) : value(x) |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | Value& value; |
| 22 | }; |
| 23 | }}} // namespace boost::parameter::aux |
| 24 | |
| 25 | #include <boost/parameter/config.hpp> |
| 26 | |
| 27 | namespace boost { namespace parameter { namespace aux { |
| 28 | |
| 29 | // lazy_default -- A wrapper for the default value computation function |
| 30 | // passed by the user when resolving the value of the parameter with the |
| 31 | // given keyword. |
| 32 | #if BOOST_WORKAROUND(__EDG_VERSION__, <= 300) |
| 33 | // These compilers need a little extra help with overload resolution; |
| 34 | // we have empty_arg_list's operator[] accept a base class |
| 35 | // to make that overload less preferable. |
| 36 | template <typename KW, typename DefaultComputer> |
| 37 | struct lazy_default_base |
| 38 | { |
| 39 | inline BOOST_CONSTEXPR lazy_default_base(DefaultComputer& x) |
| 40 | : compute_default(x) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | DefaultComputer& compute_default; |
| 45 | }; |
| 46 | |
| 47 | template <typename KW, typename DefaultComputer> |
| 48 | struct lazy_default |
| 49 | : ::boost::parameter::aux::lazy_default_base<KW,DefaultComputer> |
| 50 | { |
| 51 | inline BOOST_CONSTEXPR lazy_default(DefaultComputer& x) |
| 52 | : ::boost::parameter::aux::lazy_default_base<KW,DefaultComputer>(x) |
| 53 | { |
| 54 | } |
| 55 | }; |
| 56 | #else // !BOOST_WORKAROUND(__EDG_VERSION__, <= 300) |
| 57 | template <typename KW, typename DefaultComputer> |
| 58 | struct lazy_default |
| 59 | { |
| 60 | inline BOOST_CONSTEXPR lazy_default(DefaultComputer& x) |
| 61 | : compute_default(x) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | DefaultComputer& compute_default; |
| 66 | }; |
| 67 | #endif // EDG workarounds needed. |
| 68 | }}} // namespace boost::parameter::aux |
| 69 | |
| 70 | #if BOOST_WORKAROUND(__EDG_VERSION__, <= 300) |
| 71 | #define BOOST_PARAMETER_lazy_default_fallback \ |
| 72 | ::boost::parameter::aux::lazy_default_base |
| 73 | /**/ |
| 74 | #else |
| 75 | #define BOOST_PARAMETER_lazy_default_fallback \ |
| 76 | ::boost::parameter::aux::lazy_default |
| 77 | /**/ |
| 78 | #endif |
| 79 | |
| 80 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) |
| 81 | |
| 82 | #include <utility> |
| 83 | |
| 84 | namespace boost { namespace parameter { namespace aux { |
| 85 | |
| 86 | template <typename Keyword, typename Value> |
| 87 | struct default_r_ |
| 88 | { |
| 89 | inline BOOST_CONSTEXPR default_r_(Value&& x) |
| 90 | : value(::std::forward<Value>(x)) |
| 91 | { |
| 92 | } |
| 93 | |
| 94 | Value&& value; |
| 95 | }; |
| 96 | }}} // namespace boost::parameter::aux |
| 97 | |
| 98 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING |
| 99 | #endif // include guard |
| 100 | |
| 101 | |