Conversation started Aug 17, 2011 at 15:51.
Aug 17, 2011 15:51
@RMartinhoFernandes I'm not exactly sure what I did is legal.
Als
Als
@LucDanton: Want me to call the cops? :P
Oh noes!
Als
Als
@LucDanton: what did you do, anyways?
Try to use defaulted template parameters for SFINAE.
42 mins ago, by Luc Danton
    template<
        typename C
        , typename = decltype( (std::declval<C>().*std::declval<element_type>()) )
    >
    Ret
    operator()(C&& c, Args... a) const;

    template<
        typename C
        , typename = decltype( (std::declval<C>()->*std::declval<element_type>()) )
        , typename = void
    >
    Ret
    operator()(C&& c, Args... a) const;
    template<
        typename C
    >
    decltype( std::declval<C>().*std::declval<element_type>(), Ret() )
    operator()(C&& c, Args... a) const;

    template<
        typename C
    >
    decltype( (*std::declval<C>()).*std::declval<element_type>(), Ret() )
    operator()(C&& c, Args... a) const;
New approach
And now I have too much SFINAE and overload resolution doesn't succeed.
That requires DefaultConstructible.
Why not decltype( std::declval<C>().*std::declval<element_type>(), std::declval<Ret>() )?
Aug 17, 2011 15:59
I was going to mention that: by this point, I might as well forget Ret and use std::result_of.
Wait can std::result_of work with SFINAE?
template<
    typename C
>
decltype( (std::declval<C>().*std::declval<element_type>())(std::declval<Args>()...) )
operator()(C&& c, Args... a) const;
Nets me a hard error.
Where do people go to learn codes like this? I learned CSS, HTML and JavaScript on w3schools.com.
@SilverHorn C++ you learn from a book
Those queer things made of stacked dumb paper.
Some are also available in smart paper though.
Hello @EtiennedeMartel :)
Where is SFINAE in the standard (N3290 preferably)?
Aug 17, 2011 16:10
14.8.3.1
Don't know if there are others applicable paragraphs.
The wording in that paragraph doesn't seem to apply to most uses of SFINAE. For instance usage of std::enable_if.
14.8.2/8 helps make it clear.
> If a substitution results in an invalid type or expression, type deduction fails. An invalid type or expression is one that would be ill-formed if written using the substituted arguments. (...)
I huh can't find your reference. I'm slow.
Er, it's on page 383.
So that does mean that my original use of defaulted template parameters should trigger SFINAE then.
 
Conversation ended Aug 17, 2011 at 16:17.