diff --git a/include/boost/make_unique.hpp b/include/boost/make_unique.hpp index c163673..4dc82c3 100644 --- a/include/boost/make_unique.hpp +++ b/include/boost/make_unique.hpp @@ -1,11 +1,11 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #ifndef BOOST_MAKE_UNIQUE_HPP_INCLUDED #define BOOST_MAKE_UNIQUE_HPP_INCLUDED diff --git a/include/boost/smart_ptr/detail/up_if_array.hpp b/include/boost/smart_ptr/detail/up_if_array.hpp deleted file mode 100644 index 7e62d10..0000000 --- a/include/boost/smart_ptr/detail/up_if_array.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ -#ifndef BOOST_SMART_PTR_DETAIL_UP_IF_ARRAY_HPP -#define BOOST_SMART_PTR_DETAIL_UP_IF_ARRAY_HPP - -#include - -namespace boost { - namespace detail { - template - struct up_if_array; - - template - struct up_if_array { - typedef std::unique_ptr type; - }; - } -} - -#endif diff --git a/include/boost/smart_ptr/detail/up_if_not_array.hpp b/include/boost/smart_ptr/detail/up_if_not_array.hpp deleted file mode 100644 index fd74f25..0000000 --- a/include/boost/smart_ptr/detail/up_if_not_array.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ -#ifndef BOOST_SMART_PTR_DETAIL_UP_IF_NOT_ARRAY_HPP -#define BOOST_SMART_PTR_DETAIL_UP_IF_NOT_ARRAY_HPP - -#include - -namespace boost { - namespace detail { - template - struct up_if_not_array { - typedef std::unique_ptr type; - }; - - template - struct up_if_not_array { - }; - - template - struct up_if_not_array { - }; - } -} - -#endif diff --git a/include/boost/smart_ptr/make_unique.hpp b/include/boost/smart_ptr/make_unique.hpp index 90402e2..f1f4a7c 100644 --- a/include/boost/smart_ptr/make_unique.hpp +++ b/include/boost/smart_ptr/make_unique.hpp @@ -1,15 +1,105 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014-2015 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP #define BOOST_SMART_PTR_MAKE_UNIQUE_HPP -#include -#include +#include +#include + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif + +namespace boost { +namespace detail { +template +struct up_if_object { + typedef std::unique_ptr type; +}; + +template +struct up_if_object { +}; + +template +struct up_if_object { +}; + +template +struct up_if_array { +}; + +template +struct up_if_array { + typedef std::unique_ptr type; +}; + +template +struct up_value { + typedef T&& type; +}; + +template +struct up_element { +}; + +template +struct up_element { + typedef T type; +}; +} /* detail */ + +template +inline typename detail::up_if_object::type +make_unique() +{ + return std::unique_ptr(new T()); +} + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +template +inline typename detail::up_if_object::type +make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} +#endif + +template +inline typename detail::up_if_object::type +make_unique(typename detail::up_value::type value) +{ + return std::unique_ptr(new T(std::move(value))); +} + +template +inline typename detail::up_if_object::type +make_unique_noinit() +{ + return std::unique_ptr(new T); +} + +template +inline typename detail::up_if_array::type +make_unique(std::size_t n) +{ + return std::unique_ptr(new + typename detail::up_element::type[n]()); +} + +template +inline typename detail::up_if_array::type +make_unique_noinit(std::size_t n) +{ + return std::unique_ptr(new + typename detail::up_element::type[n]); +} +} /* boost */ #endif diff --git a/include/boost/smart_ptr/make_unique_array.hpp b/include/boost/smart_ptr/make_unique_array.hpp deleted file mode 100644 index eb0528e..0000000 --- a/include/boost/smart_ptr/make_unique_array.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ -#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_ARRAY_HPP -#define BOOST_SMART_PTR_MAKE_UNIQUE_ARRAY_HPP - -#include -#include - -namespace boost { - template - inline typename boost::detail::up_if_array::type - make_unique(std::size_t size) { - typedef typename boost::detail::array_inner::type U; - return std::unique_ptr(new U[size]()); - } - - template - inline typename boost::detail::up_if_array::type - make_unique_noinit(std::size_t size) { - typedef typename boost::detail::array_inner::type U; - return std::unique_ptr(new U[size]); - } -} - -#endif diff --git a/include/boost/smart_ptr/make_unique_object.hpp b/include/boost/smart_ptr/make_unique_object.hpp deleted file mode 100644 index 9e6108a..0000000 --- a/include/boost/smart_ptr/make_unique_object.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ -#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_OBJECT_HPP -#define BOOST_SMART_PTR_MAKE_UNIQUE_OBJECT_HPP - -#include -#include -#include -#include - -namespace boost { - template - inline typename boost::detail::up_if_not_array::type - make_unique() { - return std::unique_ptr(new T()); - } - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - inline typename boost::detail::up_if_not_array::type - make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); - } -#endif - - template - inline typename boost::detail::up_if_not_array::type - make_unique(typename add_rvalue_reference::type value) { - return std::unique_ptr(new T(std::move(value))); - } - - template - inline typename boost::detail::up_if_not_array::type - make_unique_noinit() { - return std::unique_ptr(new T); - } -} - -#endif diff --git a/test/make_unique_args_test.cpp b/test/make_unique_args_test.cpp index 6c13d41..7231a8d 100644 --- a/test/make_unique_args_test.cpp +++ b/test/make_unique_args_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -41,7 +41,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ BOOST_TEST(type::instances == 0); { std::unique_ptr a1 = boost::make_unique(); @@ -139,7 +140,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_array_noinit_test.cpp b/test/make_unique_array_noinit_test.cpp index edaa67f..675c470 100644 --- a/test/make_unique_array_noinit_test.cpp +++ b/test/make_unique_array_noinit_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012-2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -30,7 +30,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ { std::unique_ptr a1 = boost::make_unique_noinit(3); BOOST_TEST(a1.get() != 0); @@ -81,7 +82,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_array_test.cpp b/test/make_unique_array_test.cpp index 8e5ea79..af0a065 100644 --- a/test/make_unique_array_test.cpp +++ b/test/make_unique_array_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -30,7 +30,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ { std::unique_ptr a1 = boost::make_unique(3); BOOST_TEST(a1.get() != 0); @@ -105,7 +106,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_array_throws_test.cpp b/test/make_unique_array_throws_test.cpp index 3efbc2a..e38b145 100644 --- a/test/make_unique_array_throws_test.cpp +++ b/test/make_unique_array_throws_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -33,7 +33,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ BOOST_TEST(type::instances == 0); try { boost::make_unique(6); @@ -70,7 +71,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_noinit_test.cpp b/test/make_unique_noinit_test.cpp index 1ef0daa..3de787c 100644 --- a/test/make_unique_noinit_test.cpp +++ b/test/make_unique_noinit_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012-2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -30,7 +30,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ { std::unique_ptr a1 = boost::make_unique_noinit(); BOOST_TEST(a1.get() != 0); @@ -58,7 +59,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_test.cpp b/test/make_unique_test.cpp index ab13c33..a2c6b99 100644 --- a/test/make_unique_test.cpp +++ b/test/make_unique_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -30,7 +30,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ { std::unique_ptr a1 = boost::make_unique(); BOOST_TEST(a1.get() != 0); @@ -65,7 +66,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_throws_test.cpp b/test/make_unique_throws_test.cpp index 9594c90..c8fdcc8 100644 --- a/test/make_unique_throws_test.cpp +++ b/test/make_unique_throws_test.cpp @@ -1,15 +1,15 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include class type { public: @@ -33,7 +33,8 @@ private: unsigned int type::instances = 0; -int main() { +int main() +{ BOOST_TEST(type::instances == 0); try { boost::make_unique(); @@ -46,7 +47,8 @@ int main() { } #else -int main() { +int main() +{ return 0; } diff --git a/test/make_unique_value_test.cpp b/test/make_unique_value_test.cpp index 03cdf47..4b34af8 100644 --- a/test/make_unique_value_test.cpp +++ b/test/make_unique_value_test.cpp @@ -1,22 +1,23 @@ /* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ #include #if !defined(BOOST_NO_CXX11_SMART_PTR) #include -#include +#include struct type { int x; int y; }; -int main() { +int main() +{ { std::unique_ptr a1 = boost::make_unique(); BOOST_TEST(a1.get() != 0); @@ -51,7 +52,8 @@ int main() { } #else -int main() { +int main() +{ return 0; }