Re constructors versus assignment:
type *variable(NULL); // this doesn't work in MSVC
type (*variable)(NULL); // this looks ugly [but works in MSVC]
type *variable = NULL; // this doesn't, but /may do an assignment +
//construction rather than construction.
Since "variable" is a plain pointer, its constructors and assignment
operators are trivial, and the compiler should easily be able to
optimise both the above variants to identical (trivial) code. It
doesn't matter how fancy "type" is; "type*" is always a plain pointer.
In other words, I believe that there's no harm or loss of efficiency
from saying
type *variable = NULL;
However, with the following two variants
smart_pointer_to<type> variable(NULL);
smart_pointer_to<type> variable = NULL;
the second could be much less efficient than the first if the designer
of the smart pointer class was not very careful.
--apb (Alan Barrett)
Received on Wed Jul 16 2003 - 02:39:43 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:20:17 MST