From 9452115ee8bfdcd547a0efbbc4d6ee0b20846774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 5 Oct 2014 18:41:40 +0200 Subject: [PATCH 1/2] Avoid being dependent on Boost.PP. --- include/boost/move/make_unique.hpp | 236 +++++++++++++++++++++++++---- 1 file changed, 205 insertions(+), 31 deletions(-) diff --git a/include/boost/move/make_unique.hpp b/include/boost/move/make_unique.hpp index e949785..4a4f99a 100644 --- a/include/boost/move/make_unique.hpp +++ b/include/boost/move/make_unique.hpp @@ -18,13 +18,6 @@ #include //for std::size_t #include -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#include -#include -#include -#include -#endif - //!\file //! Defines "make_unique" functions, which are factories to create instances //! of unique_ptr depending on the passed arguments. @@ -77,31 +70,212 @@ inline BOOST_MOVE_DOC1ST(unique_ptr, { return unique_ptr(new T(::boost::forward(args)...)); } #else - #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - #define BOOST_MOVE_PP_PARAM_LIST(z, n, data) \ - BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \ - //! - #else - #define BOOST_MOVE_PP_PARAM_LIST(z, n, data) \ - const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \ - //! - #endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - #define BOOST_MOVE_PP_PARAM_FORWARD(z, n, data) \ - ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \ - //! - - #define BOOST_MOVE_MAX_CONSTRUCTOR_PARAMETERS 10 - - #define BOOST_PP_LOCAL_MACRO(n) \ - template \ - typename ::boost::move_upmu::unique_ptr_if::t_is_not_array \ - make_unique(BOOST_PP_ENUM(n, BOOST_MOVE_PP_PARAM_LIST, _)) \ - { return unique_ptr(new T(BOOST_PP_ENUM(n, BOOST_MOVE_PP_PARAM_FORWARD, _))); } \ - //! - - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_MOVE_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() + //0 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique() + { return unique_ptr(new T()); } + //1 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + ) + ); + } + //2 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + ) + ); + } + //3 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + ) + ); + } + //4 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + ) + ); + } + //5 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + , BOOST_FWD_REF(P4) p4 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + , ::boost::forward(p4) + ) + ); + } + //6 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + , BOOST_FWD_REF(P4) p4 + , BOOST_FWD_REF(P5) p5 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + , ::boost::forward(p4) + , ::boost::forward(p5) + ) + ); + } + //7 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + , BOOST_FWD_REF(P4) p4 + , BOOST_FWD_REF(P5) p5 + , BOOST_FWD_REF(P6) p6 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + , ::boost::forward(p4) + , ::boost::forward(p5) + , ::boost::forward(p6) + ) + ); + } + //8 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + , BOOST_FWD_REF(P4) p4 + , BOOST_FWD_REF(P5) p5 + , BOOST_FWD_REF(P6) p6 + , BOOST_FWD_REF(P7) p7 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + , ::boost::forward(p4) + , ::boost::forward(p5) + , ::boost::forward(p6) + , ::boost::forward(p7) + ) + ); + } + //9 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + , BOOST_FWD_REF(P4) p4 + , BOOST_FWD_REF(P5) p5 + , BOOST_FWD_REF(P6) p6 + , BOOST_FWD_REF(P7) p7 + , BOOST_FWD_REF(P8) p8 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + , ::boost::forward(p4) + , ::boost::forward(p5) + , ::boost::forward(p6) + , ::boost::forward(p7) + , ::boost::forward(p8) + ) + ); + } + //10 arg + template + typename ::boost::move_upmu::unique_ptr_if::t_is_not_array + make_unique( BOOST_FWD_REF(P0) p0 + , BOOST_FWD_REF(P1) p1 + , BOOST_FWD_REF(P2) p2 + , BOOST_FWD_REF(P3) p3 + , BOOST_FWD_REF(P4) p4 + , BOOST_FWD_REF(P5) p5 + , BOOST_FWD_REF(P6) p6 + , BOOST_FWD_REF(P7) p7 + , BOOST_FWD_REF(P8) p8 + , BOOST_FWD_REF(P9) p9 + ) + { + return unique_ptr + ( new T( ::boost::forward(p0) + , ::boost::forward(p1) + , ::boost::forward(p2) + , ::boost::forward(p3) + , ::boost::forward(p4) + , ::boost::forward(p5) + , ::boost::forward(p6) + , ::boost::forward(p7) + , ::boost::forward(p8) + , ::boost::forward(p9) + ) + ); + } #endif From ca7d74970a21bdd6fb8f7b8220c1be422e2622a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 5 Oct 2014 18:41:57 +0200 Subject: [PATCH 2/2] Removed some extra spaces. --- include/boost/move/detail/config_begin.hpp | 6 +++--- include/boost/move/detail/config_end.hpp | 2 +- include/boost/move/detail/workaround.hpp | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/boost/move/detail/config_begin.hpp b/include/boost/move/detail/config_begin.hpp index 7e90c3b..edc25d4 100644 --- a/include/boost/move/detail/config_begin.hpp +++ b/include/boost/move/detail/config_begin.hpp @@ -12,7 +12,7 @@ #endif #ifdef BOOST_MSVC - #pragma warning (push) - #pragma warning (disable : 4996) // "function": was declared deprecated (_CRT_SECURE_NO_DEPRECATE/_SCL_SECURE_NO_WARNINGS) - #pragma warning (disable : 4675) // "function": resolved overload was found by argument-dependent lookup +# pragma warning (push) +# pragma warning (disable : 4996) // "function": was declared deprecated (_CRT_SECURE_NO_DEPRECATE/_SCL_SECURE_NO_WARNINGS) +# pragma warning (disable : 4675) // "function": resolved overload was found by argument-dependent lookup #endif diff --git a/include/boost/move/detail/config_end.hpp b/include/boost/move/detail/config_end.hpp index 7965ef3..71a99e9 100644 --- a/include/boost/move/detail/config_end.hpp +++ b/include/boost/move/detail/config_end.hpp @@ -8,5 +8,5 @@ // ////////////////////////////////////////////////////////////////////////////// #if defined BOOST_MSVC - #pragma warning (pop) +# pragma warning (pop) #endif diff --git a/include/boost/move/detail/workaround.hpp b/include/boost/move/detail/workaround.hpp index 6fdf48a..1bf879c 100644 --- a/include/boost/move/detail/workaround.hpp +++ b/include/boost/move/detail/workaround.hpp @@ -11,8 +11,6 @@ #ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP #define BOOST_MOVE_DETAIL_WORKAROUND_HPP -#include - #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #define BOOST_MOVE_PERFECT_FORWARDING #endif @@ -25,6 +23,4 @@ #define BOOST_MOVE_I , #define BOOST_MOVE_DOCIGN(T1) T1 -#include - #endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP