fork download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. template<class T, class... Args>
  5. T* nalloc(Args&&... args) {
  6. return reinterpret_cast<T*>( new T{std::forward<Args>(args)...});
  7. }
  8.  
  9. int main() {
  10. typedef int five[5];
  11. five* buff = nalloc<int[5]>(1,2,3,4,5);
  12. for( int x : *buff ) {
  13. std::cout << x << "\n";
  14. }
  15. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1
2
3
4
5