[cfe-dev] [libc++] c++14 return type deduction usage should be limited
Marshall Clow
mclow.lists at gmail.com
Wed Aug 7 10:56:39 PDT 2013
On Aug 6, 2013, at 3:39 PM, Zhihao Yuan <lichray at gmail.com> wrote:
> Hi, hackers:
>
> I noticed that in include/functional:
>
> _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const
>
> is widely used to support C++14 type deduced function objects:
>
> http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3421.htm
>
> However, in the standard text, the return type is specified with
>
> -> decltype(std::forward<T>(t) + std::forward<U>(u));
>
> There is a slight difference between using return type deduction and
> writing `decltype` out explicitly, because the later case triggers
> SFINAE, while the first case does not. See:
>
> http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3638.html
>
> "SFINAE
>
> Since the return type is deduced by instantiating the template, if the
> instantiation is ill-formed, this causes an error rather than a
> substitution failure. [...]"
>
> I suggest to obey the standard here, even such a behavior may
> (arguably) not be intentional.
>
> BTW, in the adopted text, each of the new type deduced function
> class has a `is_transparent` typedef, so…
Well, crud.
I did that - and I left those bits off because I convinced myself that the two formulations were the same.
I can apply your patch if you would like - but do you have any ideas for writing test cases?
-- Marshall
Marshall Clow Idio Software <mailto:mclow.lists at gmail.com>
A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
-- Yu Suzuki
More information about the cfe-dev
mailing list