fork(4) download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. typedef int A[];
  6.  
  7. void f(A&& a) {
  8. cout << a[1] << '\n';
  9. }
  10.  
  11. int main() {
  12. f(std::make_unique<A>(10))
  13. // your code goes here
  14. return 0;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:23: error: invalid initialization of reference of type ‘int (&&)[]’ from expression of type ‘std::_MakeUniq<int []>::__array’ {aka ‘std::unique_ptr<int [], std::default_delete<int []> >’}
  f(std::make_unique<A>(10))
    ~~~~~~~~~~~~~~~~~~~^~~~
prog.cpp:7:6: note: in passing argument 1 of ‘void f(int (&&)[])’
 void f(A&& a) {
      ^
stdout
Standard output is empty