13 Mar
2009
13 Mar
'09
3:23 p.m.
Dominique Devienne:
Does using the explicit keyword precludes the "type var = rhs;" <==> "type var(rhs);" equivalence that I've assimilated (incorrectly?) into my mental model of C++?
Yes. T x = v; causes an implicit conversion of v to T, with which x is then copy-constructed. This is routinely optimized to T x( v ); but the compiler is still required to check for the presence of an implicit conversion (which 'explicit' prevents) and an accessible copy constructor.