File indexing completed on 2025-08-03 08:19:41
0001 #include <cstddef>
0002 #include <memory>
0003 #include <type_traits>
0004 #include <utility>
0005
0006 namespace std {
0007 template<class T> struct _Unique_if {
0008 typedef unique_ptr<T> _Single_object;
0009 };
0010
0011 template<class T> struct _Unique_if<T[]> {
0012 typedef unique_ptr<T[]> _Unknown_bound;
0013 };
0014
0015 template<class T, size_t N> struct _Unique_if<T[N]> {
0016 typedef void _Known_bound;
0017 };
0018
0019 template<class T, class... Args>
0020 typename _Unique_if<T>::_Single_object
0021 make_unique(Args&&... args) {
0022 return unique_ptr<T>(new T(std::forward<Args>(args)...));
0023 }
0024
0025 template<class T>
0026 typename _Unique_if<T>::_Unknown_bound
0027 make_unique(size_t n) {
0028 typedef typename remove_extent<T>::type U;
0029 return unique_ptr<T>(new U[n]());
0030 }
0031
0032 template<class T, class... Args>
0033 typename _Unique_if<T>::_Known_bound
0034 make_unique(Args&&...) = delete;
0035 }