-1

I have been seen following type of code when i browsing Quora.

#include <iostream>
int f() 
{ 
   return 1; 
}

int main()
{
    int (&var1)() = f;
    using X = int(&)();
    int i = reinterpret_cast<X>(var1)();
    std::cout << " i = " << i << '\n';
}

So, What does using X = int(&)() do?

msc
  • 33,420
  • 29
  • 119
  • 214

1 Answers1

2

The statement is making X be an alias to the type on the right hand side of the equal sign.

That alias is then being used in the next statement.

See this reference page on the using keyword.

tambre
  • 4,625
  • 4
  • 42
  • 55
Walt Stoneburner
  • 2,562
  • 4
  • 24
  • 37