Eric Friedman wrote: > Peter Dimov wrote: >> Eric Friedman wrote: >>> Peter Dimov wrote: >> [...] >>>> template <class T, ...> T & extract(variant<...> & operand); >>>> template <class T, ...> T const & extract(variant<...> const & >>>> operand); template <class T, ...> T * extract(variant<...> * >>>> operand); >>>> template <class T, ...> T const * extract(variant<...> const * >>>> operand); >>>> >>>> it's no longer ambiguous. >>> >>> I believe it is. The following (admittedly silly) example fails to >>> compile under Comeau: >>> >>> // -- BEGIN CODE EXAMPLE -- >>> template <class T, class Extractable> T & extract(Extractable & >>> operand); template <class T, class Extractable> T const & >>> extract(Extractable const & operand); >>> >>> template <class T, class Extractable> T * extract(Extractable * >>> operand); template <class T, class Extractable> T const * >>> extract(Extractable const * operand); >> >> This is not what I wrote above. > > OK, I believe I see what you're saying. > > Problem is that I was trying to design a general boost::extract<> > facility, one that needs not be specialized for each type. (Indeed, > with my design, visitable types need not be cognizant of the facility > at all.)
I missed that part. ;-) Still, I consider the function template interface better, even for a general extract facility. Users that only extract from variants need not pay extra for a generic interface that they don't need. You can make a generic function template interface by using metaprogramming, but I don't know how well the compilers will handle it. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost