• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkMakeUnique_DEFINED
9 #define SkMakeUnique_DEFINED
10 
11 #include <memory>
12 
13 namespace skstd {
14 
15 // std::make_unique is in C++14
16 template<typename T, typename... Args>
make_unique(Args &&...args)17 std::unique_ptr<T> make_unique(Args&&... args) {
18     return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
19 }
20 
21 template<typename T>
make_unique_default(size_t n)22 std::unique_ptr<T> make_unique_default(size_t n) {
23     return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]);
24 }
25 
26 }
27 
28 #endif  // SkMakeUnique_DEFINED
29