fork(1) download
  1. #include <memory>
  2. #include <utility>
  3. #include <type_traits>
  4.  
  5. template <typename T, typename ...Args>
  6. std::unique_ptr<T> make_unique(Args &&... args)
  7. {
  8. return std::unique_ptr<T>(new typename std::conditional<std::is_array<T>::value,
  9. typename std::remove_extent<T>::type[sizeof...(Args)],
  10. T>::type { std::forward<Args>(args)... });
  11. }
  12.  
  13.  
  14. int main()
  15. {
  16. auto p = make_unique<int[]>(11, 22, 33);
  17. }
  18.  
Success #stdin #stdout 0s 3012KB
stdin
Standard input is empty
stdout
Standard output is empty