Akim Demaille
I think it now does what I want, if you're curious:
Looks neat!
I made several changes:
[...]
- but so I also need to support null pointers, so I have added support for nullptr and operator bool.
I think you forgot to add that support in some of poly_older ctors and assignment operators: poly_holder(const poly_holder& x); poly_holder& operator=(const poly_holder& x); poly_holder& operator=(poly_holder&& x);
- FWIW, your operator== for poly_flyweight was uselessly deep, comparing the addresses should suffice
You're right, your version is the right one.
(actually, shouldn't Boost.Flyweight provide these operators itself? Is there any possibility that something else would be wanted? I'm also thinking about hashing here).
Currently, the following overloads are provided: ==,<,!=,>,>=,<=,swap,<< hash was not provided for no particular reason, but I'll consider adding it (both for boost::hash and std::hash). As for what these overloads are not serving your poly_flyweight, the problem is that in poly_flyweight<Base> f1,f2; f1==f2; // ambiguity the == expression is probing many implicit conversions (to poly_flyweight<Base>, to poly_holder<Base>, to Base) resulting in ambiguities: this is why you need to suply your own == etc. for poly_flyweight. Good luck with you project. Joaquín M López Muñoz Telefónica