Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2003-11-14 13:50:49


Brian McNamara wrote:
> There are a number of recent messages on this thread, and I've chosen to
> reply "in batch".
>
> Daniel Wallin:
>
>>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.
>
>
> This strategy uses structural conformance. I want named conformance.
> (Named conformance is not as susceptible to accidental conformance.)

What about tagging the clone function?

   struct clone_factory_tag {};

   template<class T>
   T* clone(clone_factory_tag, const T& x)
   {
       return new T(x);
   }

   ...

   Foo* clone(clone_factory_tag, const Foo& x)
   {
       return x.clone();
   }

-- 
Daniel Wallin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk