//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany /// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Dr. Frank Celler //////////////////////////////////////////////////////////////////////////////// #ifndef ARANGODB_BASICS_MAKE__UNIQUE_H #define ARANGODB_BASICS_MAKE__UNIQUE_H 1 #include #include #include #include // VS 2013 and VS 2015 already provide std::make_unique #ifndef _WIN32 // c++98: 199711 (not supported) // c++11: 201103 (no std::make_unique) // c++14: 201402 (std::make_unique included) #if __cplusplus == 201103L //////////////////////////////////////////////////////////////////////////////// /// Provide a make_unique() function for C++11 too /// http://stackoverflow.com/questions/17902405/how-to-implement-make-unique-function-in-c11 //////////////////////////////////////////////////////////////////////////////// namespace std { template struct _Unique_if { typedef unique_ptr _Single_object; }; template struct _Unique_if { typedef unique_ptr _Unknown_bound; }; template struct _Unique_if { typedef void _Known_bound; }; template typename _Unique_if::_Single_object make_unique(Args&&... args) { return unique_ptr(new T(std::forward(args)...)); } template typename _Unique_if::_Unknown_bound make_unique(size_t n) { typedef typename remove_extent::type U; return unique_ptr(new U[n]()); } template typename _Unique_if::_Known_bound make_unique(Args&&...) = delete; } // namespace std #endif #endif #endif