cppassist  1.0.0.f4fab4f962ff
C++ sanctuary for small but powerful and frequently required, stand alone features.
make_unique.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 #include <memory>
6 
7 #include <cppassist/cppassist_api.h>
8 
9 
10 namespace cppassist
11 {
12 
13 
14 // based on the implementation from libc++ (MIT-licensed)
15 
16 
17 namespace detail
18 {
19 
20 
21 template<class T>
22 struct CPPASSIST_TEMPLATE_API UniqueIf
23 {
24  using UniqueSingle = std::unique_ptr<T>;
25 };
26 
27 template<class T>
28 struct CPPASSIST_TEMPLATE_API UniqueIf<T[]>
29 {
30  using UniqueArrayUnknownBound = std::unique_ptr<T[]>;
31 };
32 
33 template<class T, size_t N>
34 struct CPPASSIST_TEMPLATE_API UniqueIf<T[N]>
35 {
36  using UniqueArrayKnownBound = void;
37 };
38 
39 
40 } // namespace detail
41 
42 
43 template<class T, class... Args>
44 typename detail::UniqueIf<T>::UniqueSingle make_unique(Args && ... args);
45 
46 template<class T>
48 
49 template<class T, class... Args>
50 typename detail::UniqueIf<T>::UniqueArrayKnownBound make_unique(Args && ...) = delete;
51 
52 
53 } // namespace cppassist
54 
55 
Definition: ArgumentParser.h:12
std::unique_ptr< T > UniqueSingle
Definition: make_unique.h:24
std::unique_ptr< T[]> UniqueArrayUnknownBound
Definition: make_unique.h:30
Definition: make_unique.h:22
detail::UniqueIf< T >::UniqueSingle make_unique(Args &&... args)
Definition: make_unique.inl:10
void UniqueArrayKnownBound
Definition: make_unique.h:36