add SPROUT_FORWARD variadic version

This commit is contained in:
bolero-MURAKAMI 2014-08-13 19:31:52 +09:00
parent ab875e84de
commit 23f24450b0
2 changed files with 20 additions and 7 deletions

View file

@ -10,8 +10,8 @@
#include <sprout/config.hpp>
#include <sprout/preprocessor/config.hpp>
#include <sprout/preprocessor/cat.hpp>
#include <sprout/preprocessor/stringize.hpp>
#include <sprout/preprocessor/cat.hpp>
#include <sprout/preprocessor/variadic/size.hpp>
//

View file

@ -10,6 +10,9 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/preprocessor/config.hpp>
#include <sprout/preprocessor/cat.hpp>
#include <sprout/preprocessor/variadic/size.hpp>
namespace sprout {
//
@ -25,20 +28,30 @@ namespace sprout {
forward(typename std::remove_reference<T>::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<decltype(::sprout::forward<TYPE>(VAR))>(VAR)
#else
# define SPROUT_FORWARD(TYPE, VAR) \
# define SPROUT_FORWARD_2(TYPE, VAR) \
::sprout::forward<TYPE>(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