
26 Feb
2004
26 Feb
'04
11:32 a.m.
Bjorn.Karlsson@readsoft.com wrote:
From: Vladimir Prus [mailto:ghost@cs.msu.su]
The experience in my case is very simple. I had two bugs because constructor is not explicit. I've just made it explicit locally, recomplied and got no complication errors, so convenience was not hurted.
Yes, an explicit constructor is safer because it would cause those bugs to be detected at compile time, but convenience *is* hurt:
std::vector<boost::any> vec; vec.push_back(5);
With an explicit constructor, the above won't work.
That's right. I used my case, where convenience was not hurt, to illustrate the the decision that ctor should not be explicit is not entirely obvious. - Volodya