#include <iostream>

void foo( int*&&  ) { std::cout << "foo( int*&&  )\n" ; }
void foo( int&&  ) { std::cout << "foo( int&&  )\n" ; }

void bar( int* const&  ) { std::cout << "foo( int* const&  )\n" ; }
void bar( const int&  ) { std::cout << "bar( const int&  )\n" ; }

void baz( int*&  ) { std::cout << "foo( int*&  )\n" ; }
void foo( int&  ) { std::cout << "foo( int&  )\n" ; }

void foobar( int*  ) { std::cout << "foobar( int* )\n" ; }
void foobar( int  ) { std::cout << "foobar( int  )\n" ; }

int main()
{
  int a [] = {10,10,10,10,10,11,10,11};
  short s = 23 ;

  foo(a); // fine a => rvalue of type int*; passed by reference to rvalue
  foo(s); // fine s => rvalue of type int; passed by reference to rvalue

  bar(a) ; // fine a => rvalue of type int*; passed by reference to const
  bar(s) ; // fine s => rvalue of type int; passed by reference to const

  // baz(a) ; // *** error, can't pass rvalue  as reference to non-const lvalue
  //baz(s) ;  // *** error, can't pass rvalue  as reference to non-const lvalue

  foobar(a) ; // fine a => rvalue of type int*; passed by value (pass a copy of the rvalue)
  foobar(s) ; // fine s => rvalue of type int; passed by value (pass a copy of the rvalue)
}
