The topic basically says it all. I'm following a tutorial where it says type const &value
, but visual studio keeps automatically correcting it to type const& value
.
Is there a difference?
Is there a convention?
The topic basically says it all. I'm following a tutorial where it says type const &value
, but visual studio keeps automatically correcting it to type const& value
.
Is there a difference?
Is there a convention?
The way that C++ Parses tokens stipulates that these two statements will be treated equivalently, and there is no difference in the code that will be generated.
As to why MSVC keeps autocorrecting to the other, I really don't think it should, but my guess for why it does is that MSVC is helping you keep your code consistent (which is important!), and it is assuming that the way you want the code to look is in this format: type const& name
.
This format is more recognizably C++, whereas the other method, type const &name
is more C-like (despite the fact that C doesn't have references; but it does have pointers, and a similar declaration type const *name
would be more obviously C as well), and MSVC wants to enforce the C++ style.
But again; there's no functional difference between them. Both are valid, both will compile, and both will have the same behavior.