/// \file ROOT/RMakeUnique.hxx /// \ingroup Base StdExt /// \author Danilo Piparo /// \date 2017-09-22 /************************************************************************* * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_RMakeUnique #define ROOT_RMakeUnique #include #if __cplusplus < 201402L && !defined(_MSC_VER) #include #include namespace ROOT { namespace Detail { // Inspired from abseil template struct RMakeUniqueResult { using scalar = std::unique_ptr; }; template struct RMakeUniqueResult { using array = std::unique_ptr; }; template struct RMakeUniqueResult { using invalid = void; }; } // namespace Detail } // namespace ROOT namespace std { // template ::value, int>::type = 0> template typename ROOT::Detail::RMakeUniqueResult::scalar make_unique(Args &&... args) { return std::unique_ptr(new T(std::forward(args)...)); } template typename ROOT::Detail::RMakeUniqueResult::array make_unique(std::size_t size) { return std::unique_ptr(new typename std::remove_extent::type[size]()); } template typename ROOT::Detail::RMakeUniqueResult::invalid make_unique(Args &&...) = delete; } // namespace std #endif #endif