#pragma once #include namespace torch { // Reference: // https://github.com/llvm-mirror/libcxx/blob/master/include/memory#L3091 template struct unique_type_for { using value = std::unique_ptr; }; template struct unique_type_for { using unbounded_array = std::unique_ptr; }; template struct unique_type_for { using bounded_array = void; }; template typename unique_type_for::value make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } template typename unique_type_for::unbounded_array make_unique(size_t size) { using U = typename std::remove_extent::type; return std::unique_ptr(new U[size]()); } template typename unique_type_for::bounded_array make_unique(Args&&...) = delete; } // namespace torch