diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-10-28 16:10:10 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-10-28 16:10:10 +0000 |
commit | 463025a4a1aa4f9405fb2cf43429b22514277545 (patch) | |
tree | af92d9931192d131027e5cb23ee31d5a9519c836 | |
parent | 98d57112ed85e3b7892dae72020fe3da553c0af7 (diff) | |
download | gcc-463025a4a1aa4f9405fb2cf43429b22514277545.tar.gz |
2017-10-28 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/70971
* g++.dg/torture/pr70971.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254199 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr70971.C | 48 |
2 files changed, 53 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1646f4cb033..49693bca887 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-28 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/70971 + * g++.dg/torture/pr70971.C: New. + 2017-10-28 Paul Thomas <pault@gcc.gnu.org> PR fortran/81758 diff --git a/gcc/testsuite/g++.dg/torture/pr70971.C b/gcc/testsuite/g++.dg/torture/pr70971.C new file mode 100644 index 00000000000..23f33aafaba --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr70971.C @@ -0,0 +1,48 @@ +// { dg-additional-options "-std=c++14" } + +template<typename Signature> +class function; + +template<typename R, typename... Args> +class invoker_base +{ + public: + virtual ~invoker_base() { } +}; + +template<typename F, typename R, typename... Args> +class functor_invoker : public invoker_base<R, Args...> +{ + public: + explicit functor_invoker(const F& f) : f(f) { } + private: + F f; +}; + +template<typename R, typename... Args> +class function<R (Args...)> { + public: + template<typename F> + function(const F& f) : invoker(0) { + invoker = new functor_invoker<F, R, Args...>(f); + } + ~function() { + if (invoker) + delete invoker; + } + private: + invoker_base<R, Args...>* invoker; +}; + +template<typename> +struct unique_ptr { }; + +struct A {}; +template <class...> struct typelist {}; +template <class... Cs> unique_ptr<A> chooseB(typelist<Cs...>); +template <class... Cs, class Idx, class... Rest> +unique_ptr<A> chooseB(typelist<Cs...> choices, Idx, Rest... rest) { + auto f = [=](auto) { return [=] { return chooseB(choices, rest...); }; }; + function<unique_ptr<A>()> fs[]{f(Cs{})...}; +} +main() { chooseB(typelist<double, char>{}, 0, 1, 2); } |