add octa::make_box

master
Daniel Kolesa 2015-04-27 20:05:33 +01:00
parent de7ceba269
commit 709bcb1362
1 changed files with 25 additions and 0 deletions

View File

@ -431,6 +431,31 @@ namespace octa {
T *p_ptr;
D p_del;
};
template<typename T> struct __OctaBoxIf {
typedef Box<T> __OctaBox;
};
template<typename T> struct __OctaBoxIf<T[]> {
typedef Box<T[]> __OctaBoxUnknownSize;
};
template<typename T, size_t N> struct __OctaBoxIf<T[N]> {
typedef void __OctaBoxKnownSize;
};
template<typename T, typename ...A>
typename __OctaBoxIf<T>::__OctaBox make_box(A &&...args) {
return Box<T>(new T(forward<A>(args)...));
}
template<typename T>
typename __OctaBoxIf<T>::__OctaBoxUnknownSize make_box(size_t n) {
return Box<T>(new RemoveExtent<T>[n]());
}
template<typename T, typename ...A>
typename __OctaBoxIf<T>::__OctaBoxKnownSize make_box(A &&...args) = delete;
}
#endif