From 23f24450b04bf9f55a845d923e281a98d5320c22 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 13 Aug 2014 19:31:52 +0900 Subject: [PATCH] add SPROUT_FORWARD variadic version --- sprout/static_assert.hpp | 2 +- sprout/utility/forward.hpp | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sprout/static_assert.hpp b/sprout/static_assert.hpp index e4c6e0f6..ce7dda9d 100644 --- a/sprout/static_assert.hpp +++ b/sprout/static_assert.hpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include // diff --git a/sprout/utility/forward.hpp b/sprout/utility/forward.hpp index 30376c79..3b3f3610 100644 --- a/sprout/utility/forward.hpp +++ b/sprout/utility/forward.hpp @@ -10,6 +10,9 @@ #include #include +#include +#include +#include namespace sprout { // @@ -25,20 +28,30 @@ namespace sprout { forward(typename std::remove_reference::type&&) SPROUT_NOEXCEPT SPROUT_DELETED_FUNCTION_DECL } // namespace sprout -// -// SPROUT_FORWARD -// #if defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) -# define SPROUT_FORWARD(TYPE, VAR) \ +# define SPROUT_FORWARD_2(TYPE, VAR) \ static_cast(VAR))>(VAR) #else -# define SPROUT_FORWARD(TYPE, VAR) \ +# define SPROUT_FORWARD_2(TYPE, VAR) \ ::sprout::forward(VAR) #endif // // SPROUT_AUTO_FORWARD // -#define SPROUT_AUTO_FORWARD(VAR) SPROUT_FORWARD(decltype(VAR), VAR) +#define SPROUT_AUTO_FORWARD(VAR) SPROUT_FORWARD_2(decltype(VAR), VAR) + +// +// SPROUT_FORWARD +// +#if SPROUT_PP_VARIADICS +# define SPROUT_FORWARD_1(VAR) \ + SPROUT_AUTO_FORWARD(VAR) +# define SPROUT_FORWARD(...) \ + SPROUT_PP_CAT(SPROUT_FORWARD_, SPROUT_PP_VARIADIC_SIZE(__VA_ARGS__))(__VA_ARGS__) +#else +# define SPROUT_FORWARD(TYPE, VAR) \ + SPROUT_FORWARD_2(TYPE, VAR) +#endif #endif // #ifndef SPROUT_UTILITY_FORWARD_HPP