MSVC has a non-standard "extension". This means that it allows you to break the code. There is a good reason this is forbidden.
We also note that
int& a = 5;
also not legal in standard C ++.
In general, however, it is legal to initialize a const
reference with any expression that can be converted to the correct type (including the use of a conditional operator). And it is not legal to initialize a link with a value of the correct type, which the conditional operator gives under certain conditions.
source share