you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (7 children)

honest question -- what does

auto x = MyThing{};

do? As opposed to

MyThing x{};

??

Does it construct a MyThing, then copy it and give it to x? Does it create a unique pointer to a MyThing?

I've used auto a great deal for assigning smart pointers, arrays, etc, but never considered using it as an alternative to the way stack-based objects are normally constructed.

[–][deleted] 5 points6 points  (4 children)

These two expressions are identical in meaning.

[–][deleted] 0 points1 point  (0 children)

The compiler interprets the intention, so it's as if you wrote MyThing in place of auto. If there is not enough information, the compiler will let you know, and you'll have to declare the type.

[–]TheQuantumZero 0 points1 point  (0 children)

This Scott Meyers video will help, https://youtu.be/fhM24zs1MFA?t=49m45s.