Re: Question regarding copy constructor
Juha Nieminen <nospam@thanks.invalid> wrote:
?? Tiib <ootiib@hot.ee> wrote:
There certainly won't be assignment operators used in initialization. Most
coding standards suggest to write what you actually want 'A a(2);' and
to avoid writing "likely synonymous after optimizations" variants.
Then you get problems like this:
struct A { ... };
struct Comparator { bool operator()(const A&, const A&) const { ... } };
std::map<A, int, Comparator> theMap(Comparator());
(Can't see what the problem is? Try calling one of the member functions
of theMap...)
Actually, I can't right now. I have also no compiler at hand.
But I don't see how it would be relevant either. I was not proposing a
macro-like (text based) expansion from:
A a = 2;
To:
A a(2);
The second form would never occur in the source and wouldn't have to be
parsed.
What I proposed was to interpret:
A a = 2;
as:
"Call of a suitable constructor with the RHS as direct argument"
Tobi