diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2016-04-10 09:32:46 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2016-04-10 09:32:46 +0000 |
commit | 47cd5a850501819ff72865054f2d2b039690ac38 (patch) | |
tree | 3315362ca429e9e9f027bc9a504a024178b13317 /gcc | |
parent | c27e432ed83ff35dd04e2951d5aae4a20b3428b7 (diff) | |
download | gcc-47cd5a850501819ff72865054f2d2b039690ac38.zip gcc-47cd5a850501819ff72865054f2d2b039690ac38.tar.gz gcc-47cd5a850501819ff72865054f2d2b039690ac38.tar.bz2 |
re PR c++/69066 (SFINAE compilation error on lambda with trailing return type)
2016-04-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69066
* g++.dg/cpp1y/pr69066.C: New.
From-SVN: r234869
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/pr69066.C | 75 |
2 files changed, 80 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9784a4b..77b614b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/69066 + * g++.dg/cpp1y/pr69066.C: New. + 2016-04-09 Jerry DeLisle <jvdelisle@gcc.gnu.org> 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 0000000..263e1b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr69066.C @@ -0,0 +1,75 @@ +// PR c++/69066 +// { dg-do compile { target c++14 } } + +template <typename T> T&& declval(); + +template<typename T, T v> +struct integral_constant +{ + static constexpr T value = v; + typedef T value_type; + typedef integral_constant<T, v> type; + constexpr operator value_type() const { return value; } +}; + +typedef integral_constant<bool, true> true_type; +typedef integral_constant<bool, false> false_type; + +template <typename...> +using void_t = void; + +template <typename, typename = void> +class is_zero_callable : public false_type +{ +}; + +template <typename T> +class is_zero_callable<T, void_t<decltype(declval<T>()())>> + : public true_type +{ +}; + +template <typename TF, bool TLastStep> +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<decltype(bound_f), + is_zero_callable<decltype(bound_f)>{}>::exec(bound_f); + }; + } +}; + +template <typename TF> +struct curry_impl<TF, true> +{ + static auto exec(TF f) + { + return f(); + } +}; + +template <typename TF> +auto curry(TF f) +{ + return curry_impl<TF, is_zero_callable<decltype(f)>{}>::exec(f); +} + +int main() +{ + auto sum = [](int x, int y) + { + return x + y; + }; + + (void)curry(sum)(1)(1); +} |