Boost logo

Boost :

From: Brock Peabody (brock.peabody_at_[hidden])
Date: 2003-11-14 08:58:15

> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of Daniel Wallin
> Sent: Friday, November 14, 2003 2:43 AM
> To: Boost mailing list
> Subject: Re: [boost] Re: compile time member detection

> Why complicate things? Just make it a generic function that uses copy
> construction by default, and rely on ADL and overloading instead of
> class specialization.
> template<class T>
> T* clone(const T& t)
> {
> return new T(t);
> }
> Foo* clone(const Foo& t)
> {
> return t.clone();
> }

I'm so lazy though that I couldn't stand to have N versions of clone that
looked exactly the same, and this is just a trivial example. There are
situations where you need to do something more complicated, and there are
probably problems that can't be solved with overloading, especially when the
decisions you need to make involve choosing types.

> Restricting something to use a particular member function name is IMO a
> bad idea..

Restricting something to an exact signature is a real limitation of this
technique. It would not even work with:

   struct foo {

      foo* clone() const;

But, that's all I could squeeze from the compiler for the time being.


Boost list run by bdawes at, gregod at, cpdaniel at, john at