ModErn Text Analysis
META Enumerates Textual Applications
shim.h
Go to the documentation of this file.
1 
12 #ifndef META_UTIL_SHIM_H_
13 #define META_UTIL_SHIM_H_
14 
15 #include <memory>
16 
17 #include "meta/config.h"
18 
19 namespace meta
20 {
21 
22 #if META_HAS_STD_MAKE_UNIQUE == 0
23 
24 namespace detail
25 {
26 template <class T>
27 struct unique_if
28 {
29  using single_object = std::unique_ptr<T>;
30 };
31 
32 template <class T>
33 struct unique_if<T[]>
34 {
35  using unknown_bound = std::unique_ptr<T[]>;
36 };
37 }
38 
44 template <class T, class... Args>
45 typename detail::unique_if<T>::single_object make_unique(Args&&... args)
46 {
47  return std::unique_ptr<T>{new T(std::forward<Args>(args)...)};
48 }
49 
50 template <class T>
51 typename detail::unique_if<T>::unknown_bound make_unique(std::size_t size)
52 {
53  return std::unique_ptr<T>{new typename std::remove_extent<T>::type[size]()};
54 }
55 #else
56 using std::make_unique;
57 #endif
58 }
59 #endif
detail::unique_if< T >::single_object make_unique(Args &&... args)
Constructs a unique ptr in place.
Definition: shim.h:45
Definition: shim.h:27
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retrieval, data mining, and other applications of text processing.
Definition: analyzer.h:25