Mar 10, 2012

[c++11] 'auto' trap

Technically, if the type of the initializing expression has an explicit copy constructor, only
direct initialization is permitted. From Daniel Krügler:
struct Explicit {
Explicit(){}
explicit Explicit(const Explicit&){}
} ex;
auto ex2 = ex; // Error
auto ex3(ex); // OK

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.