Boost logo

Boost :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-03-12 13:35:54


On Mon, 2007-03-12 at 10:06 -0700, Noah Roberts wrote:
> I'm still trying to get the video to load...damn google videos can never
> seem to complete... so if this is answered in the video forgive me for
> asking again.

It is answered in the video, in the (short) discussion of Concept-Based
Overloading, but I'll give the shorter answer here:

> Will this allow me to instantiate based on what concept is followed?
> For instance, with traits I might do something like the following:
>
> template <typename T>
> struct is_floating { static bool const value = true; };
>
> template <typename T>
> typename enable_if<is_floating<T>, bool>::type f(T value) {...}
>
> template <typename T>
> typename enable_if<is_somethingelse<T>, bool>::type f(T value) {...}

Sure, just overload f with different concept requirements:

  template<typename T> requires Floating<T> void f(T value) { ... }
  template<typename T> requires SomethingElse<T> void f(T value) { ... }

  Cheers,
  Doug


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