From: Paolo Carlini Date: Sun, 10 Apr 2016 09:32:46 +0000 (+0000) Subject: re PR c++/69066 (SFINAE compilation error on lambda with trailing return type) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47cd5a850501819ff72865054f2d2b039690ac38;p=gcc.git re PR c++/69066 (SFINAE compilation error on lambda with trailing return type) 2016-04-10 Paolo Carlini PR c++/69066 * g++.dg/cpp1y/pr69066.C: New. From-SVN: r234869 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9784a4b6f05..77b614b2db7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-10 Paolo Carlini + + PR c++/69066 + * g++.dg/cpp1y/pr69066.C: New. + 2016-04-09 Jerry DeLisle PR fortran/68566 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr69066.C b/gcc/testsuite/g++.dg/cpp1y/pr69066.C new file mode 100644 index 00000000000..263e1b61e9f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr69066.C @@ -0,0 +1,75 @@ +// PR c++/69066 +// { dg-do compile { target c++14 } } + +template T&& declval(); + +template +struct integral_constant +{ + static constexpr T value = v; + typedef T value_type; + typedef integral_constant type; + constexpr operator value_type() const { return value; } +}; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +template +using void_t = void; + +template +class is_zero_callable : public false_type +{ +}; + +template +class is_zero_callable()())>> + : public true_type +{ +}; + +template +struct curry_impl +{ + static auto exec(TF f) + { + // Bind `x` to subsequent calls. + return [=](auto x) + { + auto bound_f = [=](auto... xs) -> decltype(f(x, xs...)) + { + return f(x, xs...); + }; + + // Recursive step. + return curry_impl{}>::exec(bound_f); + }; + } +}; + +template +struct curry_impl +{ + static auto exec(TF f) + { + return f(); + } +}; + +template +auto curry(TF f) +{ + return curry_impl{}>::exec(f); +} + +int main() +{ + auto sum = [](int x, int y) + { + return x + y; + }; + + (void)curry(sum)(1)(1); +}