{"id":3617,"date":"2018-07-22T13:24:44","date_gmt":"2018-07-22T12:24:44","guid":{"rendered":"http:\/\/roboblog.fatal-fury.de\/?p=3617"},"modified":"2022-02-16T11:27:54","modified_gmt":"2022-02-16T10:27:54","slug":"c-guns-apply-generic-lambda-to-tuple","status":"publish","type":"post","link":"http:\/\/roboblog.fatal-fury.de\/?p=3617","title":{"rendered":"C++ Guns: apply generic lambda to tuple"},"content":{"rendered":"<p><a href=\"http:\/\/roboblog.fatal-fury.de\/?p=3474\">Part 1: print std::array with std::integer_sequence<\/a><br \/>\n<a href=\"http:\/\/roboblog.fatal-fury.de\/?p=3508\">Part 2: convert tuple to parameter pack<\/a><br \/>\n<a href=\"http:\/\/roboblog.fatal-fury.de\/?p=3514\">Part 3: print std::array with std::apply and fold<\/a><br \/>\n<a href=\"http:\/\/roboblog.fatal-fury.de\/?p=3529\">Part 4: fold over std::tuple und erzeugten Assembler Code<\/a><br \/>\n<a href=\"http:\/\/roboblog.fatal-fury.de\/?p=3538\">Part 5: fold over std::tuple of std::vector of Types ...<\/a><br \/>\n<strong>Part 6: apply generic lambda to tuple<\/strong><br \/>\n<a href=\"http:\/\/roboblog.fatal-fury.de\/?p=4994\">Part 7: Play with std::tuple and std::apply<\/a><\/p>\n<p>Hm, generic lambdas sind toll.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;typename...Args, typename Func&gt;\r\nauto func(const std::tuple&lt;Args...&gt;&amp; t, Func p) {     \r\n    auto f = &#x5B;&amp;p](const auto&amp;...x){ (p(x), ...); };\r\n    std::apply(f, t);\r\n}\r\n\r\nauto func2(const std::tuple&lt;int,double&gt;&amp; t) {\r\n    auto print_dat_shiat = &#x5B;](const auto&amp; p) { std::cout &lt;&lt; typeid(p).name() &lt;&lt; std::endl; };     \r\n    func(t, print_dat_shiat);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Part 1: print std::array with std::integer_sequence Part 2: convert tuple to parameter pack Part 3: print std::array with std::apply and fold Part 4: fold over std::tuple und erzeugten Assembler Code Part 5: fold over std::tuple of std::vector of Types ... Part 6: apply generic lambda to tuple Part 7: Play with std::tuple and std::apply Hm, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[17],"class_list":["post-3617","post","type-post","status-publish","format-standard","hentry","category-allgemein","tag-cpp"],"_links":{"self":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/3617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3617"}],"version-history":[{"count":3,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/3617\/revisions"}],"predecessor-version":[{"id":5002,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/3617\/revisions\/5002"}],"wp:attachment":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3617"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}