Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-02-05 19:46:09


On Thu, Feb 05, 2004 at 06:28:27PM -0600, Brock Peabody wrote:
> Is there an easy way to write:
>
> template <typename T> struct is_variant {
>
> typedef ??? type;
> };
>
> So far the best I can come up with is:
>
> 1) T has a member type "types" and
> 2) T is convertible to make_variant_over<T::types>::type and
> 3) make_variant_over<T::types>::type is convertible to T
>
> Does anyone have a better idea?

Perhaps I'm missing something, but why not just something like

   template <typename T> struct is_variant {
      typedef false_ type;
   };
   template <typename T1, typename T2, ... /*however many*/>
   struct is_variant<variant<T1,T2,...> > {
      typedef true_ type;
   };

?

-- 
-Brian McNamara (lorgon_at_[hidden])

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