Not a problem for me... for a while at Sandia we had a rule that all constructors should be explicit. We followed it for a while.... then it petered out.... but I do think it's a good idea. The exceptions are when you really do want implicit conversion... but those are usually pretty few and far between... and you usually know when you want to do it.
Derek On Jan 21, 2009, at 9:52 AM, Roy Stogner wrote: > > When trying to pass a NumericVector* to a function expecting a > NumericVector&, Brent Kraczek's compiler gave him this: > >> Compiling C++ (in optimized mode) ex3.C... >> ex3.C: In function 'int main(int, char**)': >> ex3.C:159: error: invalid conversion from 'NumericVector<double>*' >> to 'unsigned >> int' >> ex3.C:159: error: initializing argument 1 of >> 'NumericVector<T>::NumericVector(unsigned int) [with T = double]' >> ex3.C:159: error: cannot allocate an object of abstract type 'const >> NumericVector<double>' >> /home/bkraczek/libmesh/include/solvers/system.h:45: note: because >> the >> following virtual functions are pure within 'const >> NumericVector<double>': >> /home/bkraczek/libmesh/include/numerics/numeric_vector.h:102: >> note: void >> NumericVector<T>::close() [with T = double] > > The implicit conversion operators created by e.g. a constructor from > unsigned int might actually be a problem one of these days; any > objections to adding the explicit keyword to some of those constructor > declarations? It's technically a backwards-incompatible API change, > but if there actually is anyone out there with the mojo to be doing > such implicit conversions on purpose, they aren't going to have any > problem fixing their code. > --- > Roy > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Libmesh-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/libmesh-devel ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Libmesh-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-devel
