1 // Copyright 2015 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LIBBRILLO_BRILLO_MAKE_UNIQUE_PTR_H_ 6 #define LIBBRILLO_BRILLO_MAKE_UNIQUE_PTR_H_ 7 8 #include <memory> 9 10 namespace brillo { 11 12 // A function to convert T* into unique_ptr<T> 13 // Doing e.g. make_unique_ptr(new FooBarBaz<type>(arg)) is a shorter notation 14 // for unique_ptr<FooBarBaz<type>>(new FooBarBaz<type>(arg)) 15 // Basically the same as Chromium's make_scoped_ptr(). 16 // Deliberately not named "make_unique" to avoid conflicting with the similar, 17 // but more complex and semantically different C++14 function. 18 template <typename T> make_unique_ptr(T * ptr)19std::unique_ptr<T> make_unique_ptr(T* ptr) { 20 return std::unique_ptr<T>(ptr); 21 } 22 23 } // namespace brillo 24 25 #endif // LIBBRILLO_BRILLO_MAKE_UNIQUE_PTR_H_ 26