aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMakeUnique.h
blob: 860ea2e8a7bdde895e757a4159abcc38d99e6292 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkMakeUnique_DEFINED
#define SkMakeUnique_DEFINED

#include <memory>

namespace skstd {

// std::make_unique is in C++14
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
    return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

template<typename T>
std::unique_ptr<T> make_unique_default(size_t n) {
    return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]);
}

}

#endif  // SkMakeUnique_DEFINED