Douglas Gregor wrote:
> On Saturday 09 November 2002 07:21 pm, Aleksey Gurtovoy wrote:
> [snip some code...]
> >     template< typename T > yes_tag is_callable_helper(
> >           sink< sizeof(&T::operator()) >*
> >         );
> [snip more code...]
> 
> Won't work if there are multiple overloads of operator() or 
> if it is a function template, unfortunately :(

True.

> > But of course none of the compilers are particularly happy 
> > about it. How about adding 'is_callable<>' to the type_traits 
> > proposal and requesting a compiler support for it?
> 
> We could, but I have a hunch that we wouldn't get it. The 
> is_callable trait takes a lot of specification and only handles 
> very specific cases. If we're going to ask for something like 
> is_callable, we're better off asking for something that handles 
> more cases (i.e., "is this expression valid?" or "can I 
> instantiate this class template?").

That one is definitely needed. But I am not sure that these are mutually
exclusive wishes :). I mean, suppose we've got such facility, for instance
in form of '__is_well_formed' operator that can be used like this:

    template< typename T >
    struct has_key_type
        : mpl::bool_c<__is_well_formed(typename T::key_type)>
    {
    };

or

    template< typename T >
    struct is_default_constructible
        : mpl::bool_c<__is_well_formed(T())>
    {
    };

Would it be enough for you to implement the 'is_callable' trait with the
desired behavior?

Aleksey
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to