Boost logo

Boost Users :

From: Stephan Tolksdorf (andorxor_at_[hidden])
Date: 2006-07-26 05:01:22


> Another part of this thread mentioned assignment operator templates. Please
> remember that C++ does not consider such templates when determining if an
> automatically-defined copying assignment operator is needed. Such an
> operator is always a non-template, even if there's a operator template with
> a pattern that could match. If automatically-defined copying assignment
> operator won't do what the assignment operator template would, then you must
> manually recreate the routine with an explicitly-defined non-template
> copying assignment operator. (A similar rule exists for the copy
> constructor, such that it won't consider possibly-matching constructor
> templates.)

The situation with regard to template assignment operators and template
constructors is more subtle than many people think. In certain
situations they _will_ be used for copies, even in the presence of
implicitly defined default functions.
Have a look at (especially the postings from kanze):
http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/eca7b43d751008cd/90cc0b4441afb64e

Regards,
   Stephan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net