On 2014-05-12, 1:07 PM, Boris Zbarsky wrote:
Background: in C++, one-argument constructors are implicit.What this means is that given this class declaration: class Foo { public: Foo(int arg); passAFoo(const Foo& arg); }; This bit of C++: Foo foo(5); foo.passAFoo(10); will compile and construct a temporary Foo that it passes to passAFoo. This can be a pretty serious footgun, especially in cases when the constructor is passed a pointer and takes ownership of that pointer: accidentally passing a pointer where an object of is expected will do bad things. So I'd like to propose that our C++ style require one-arg constructors to be marked explicit unless there's a clear comment explaining why the constructor is implicit. Thoughts?
I strongly support this. _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

