/* *************************************************************************** * * FastFlow is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 as * published by the Free Software Foundation. * Starting from version 3.0.1 FastFlow is dual licensed under the GNU LGPLv3 * or MIT License (https://github.com/ParaGroup/WindFlow/blob/vers3.x/LICENSE.MIT) * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * **************************************************************************** */ #ifndef FF_MAKEUNIQUE_HPP #define FF_MAKEUNIQUE_HPP #include #include #include #if __cplusplus < 201400L // to check // C++11 implementation of make_unique #if (__cplusplus >= 201103L) || (defined __GXX_EXPERIMENTAL_CXX0X__) || (defined(HAS_CXX11_VARIADIC_TEMPLATES)) template std::unique_ptr make_unique_helper(std::false_type, Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } template std::unique_ptr make_unique_helper(std::true_type, Args&&... args) { static_assert(std::extent::value == 0, "make_unique() is forbidden, please use make_unique()."); typedef typename std::remove_extent::type U; return std::unique_ptr(new U[sizeof...(Args)]{std::forward(args)...}); } template std::unique_ptr make_unique(Args&&... args) { return make_unique_helper(std::is_array(), std::forward(args)...); } #endif #else using std::make_unique;// need to check if only the name is sufficient #endif #endif // FF_MAKEUNIQUE_HPP