Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11207
| From | Edek <edek.pienkowski@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: ADL fails for friend functions... |
| Date | 2011-11-02 16:08 +0100 |
| Organization | ATMAN - ATM S.A. |
| Message-ID | <j8rmaj$dss$1@node2.news.atman.pl> (permalink) |
| References | <22b4a754-8c28-494a-ba95-bcbb7bccdc57@u24g2000pru.googlegroups.com> <j8rh64$8b6$1@node2.news.atman.pl> <1fcc24a5-ebf6-430e-93d7-de1ae1ab289d@a12g2000prb.googlegroups.com> |
On 11/02/2011 03:28 PM, Werner wrote: > On Nov 2, 3:40 pm, Edek<edek.pienkow...@gmail.com> wrote: > > I've deliberately not defined the friend outside. The question > still stands - can you call join in any other way than by > removing Y's join from the overload set? "Using" does not remove Y::join from overload set. It adds n1::join. > >> Could you quote directly, I am confused with what you wrote, it does not >> fit anything I can come up with. > > Quote Modern C++ Design Ch 7.4: > > "However, experience has proven that member functions are not very > suitable for smart pointers. The reason is that the interaction > between member function calls for the smart pointer for the > pointed-to object can be extremely confusing." Ah, yes, I missed the simplest possible thing. If my opinion matters at all, + has the same problem. You "never know" if you are adding 1 to a pointer to int or to the int-pointed-to. And if an Object has a parent Object, you never know if it is the parent or the parent's parent. Oh, well... I can live with that. Friend reset is imo worse, can call a member of class where it is used by mistake, or in a better case cause ambiguity, though VC sometimes takes shortcuts here. > > I've noticed that in Loki he has, depending on compiler either > defined the friends in the class or in the namespace... > > For this reason (ADL not kicking in automatically if overload > exists) I'm beginning to think that this was boosts choice for using > members instead of non-members in their smart pointers. Don't know. Maybe you can dig mail archives for discussions. For me personally, the consequence of what I wrote above is that the programmer does have to keep track of what is a pointer and what is not a pointer. While the -> instead of . does happen in my case sometimes (when I change a ref to a ptr or the opposite) I have never hit the described problem. I wonder only if I become to hit this problem since I started using auto a lot. Still, member seems more natural to me, I find it more readable. Also note that reset(whatever) will match reset(T) if whatever is convertible to T and there is no preferred alternative and reset is not a member. Edek
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ADL fails for friend functions... Werner <werasm@gmail.com> - 2011-11-02 06:23 -0700
Re: ADL fails for friend functions... Edek <edek.pienkowski@gmail.com> - 2011-11-02 14:40 +0100
Re: ADL fails for friend functions... Werner <werasm@gmail.com> - 2011-11-02 07:28 -0700
Re: ADL fails for friend functions... Edek <edek.pienkowski@gmail.com> - 2011-11-02 16:08 +0100
Re: ADL fails for friend functions... Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-02 12:34 -0400
csiph-web