22 #ifndef GEARS_UTILITY_HELPERS_HPP
23 #define GEARS_UTILITY_HELPERS_HPP
28 #include <type_traits>
35 using single = std::unique_ptr<T>;
39 struct unique_type<T[]> {
40 using array = std::unique_ptr<T[]>;
43 template<
typename T,
size_t N>
44 struct unique_type<T[N]> {
66 template<
typename T,
typename... Args>
67 constexpr std::array<T,
sizeof...(Args)>
make_array(Args&&... args) {
68 return std::array<T,
sizeof...(Args)>{{ std::forward<Args>(args)... }};
84 template<
typename T,
typename... Args>
85 inline typename detail::unique_type<T>::single
make_unique(Args&&... args) {
86 return std::unique_ptr<T>{
new T(std::forward<Args>(args)...)};
98 inline typename detail::unique_type<T>::array
make_unique(
size_t size) {
99 using U =
typename std::remove_extent<T>::type;
100 return std::unique_ptr<T>{
new U[size]()};
103 template<
typename T,
typename... Args>
104 inline typename detail::unique_type<T>::unknown
make_unique(Args&&... args) =
delete;
108 #endif // GEARS_UTILITY_HELPERS_HPP