ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
make_unique.h
Go to the documentation of this file.
1#ifndef MAKE_UNIQUE_H
2#define MAKE_UNIQUE_H
3
4#if (!defined(_MSC_VER) && __cplusplus < 201402L)
5// std::make_unique reference implementation for linux c++11 mode compilers
6
7#include <cstddef>
8#include <memory>
9#include <type_traits>
10#include <utility>
11
12namespace std {
13 template<class T> struct _Unique_if {
14 typedef unique_ptr<T> _Single_object;
15 };
16
17 template<class T> struct _Unique_if<T[]> {
18 typedef unique_ptr<T[]> _Unknown_bound;
19 };
20
21 template<class T, size_t N> struct _Unique_if<T[N]> {
22 typedef void _Known_bound;
23 };
24
25 template<class T, class... Args>
27 make_unique(Args&&... args) {
28 return unique_ptr<T>(new T(std::forward<Args>(args)...));
29 }
30
31 template<class T>
32 typename _Unique_if<T>::_Unknown_bound
33 make_unique(size_t n) {
34 typedef typename remove_extent<T>::type U;
35 return unique_ptr<T>(new U[n]());
36 }
37
38 template<class T, class... Args>
39 typename _Unique_if<T>::_Known_bound
40 make_unique(Args&&...) = delete;
41}
42
43#endif
44
45#endif
STL namespace.
_Unique_if< T >::_Single_object make_unique(Args &&... args)
Definition make_unique.h:27
unique_ptr< T[]> _Unknown_bound
Definition make_unique.h:18
unique_ptr< T > _Single_object
Definition make_unique.h:14