{"id":309,"date":"2018-09-13T10:00:00","date_gmt":"2018-09-13T08:00:00","guid":{"rendered":"https:\/\/www.scionova.com\/?p=309"},"modified":"2018-09-13T14:43:10","modified_gmt":"2018-09-13T12:43:10","slug":"6-useful-new-features-in-c17-part-5","status":"publish","type":"post","link":"https:\/\/www.scionova.com\/en\/6-useful-new-features-in-c17-part-5\/","title":{"rendered":"6 Useful New Features in C++17 &#8211; Part 5"},"content":{"rendered":"<h3>Constexpr lambdas<\/h3>\n<p>Since C++11 we are able to use the constexpr specifier which evaluates the expression at compile time, with C++17 lambdas can also be constant expressions. One use case could be to initialize constexpr variables that depend on other constexpr variables. See the following example:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-317\" src=\"https:\/\/scionova.evdy.se\/wp-content\/uploads\/2018\/08\/constexprlambda-300x171.png\" alt=\"\" width=\"768\" height=\"438\" srcset=\"https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/constexprlambda-300x171.png 300w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/constexprlambda-768x437.png 768w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/constexprlambda-1024x583.png 1024w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/constexprlambda.png 1360w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/p>\n<p>This example maybe is silly but imagine a much more complex dependency and the array consists of more complex elements than simple integers.<\/p>\n<h3><strong>Compiler Support<\/strong><\/h3>\n<p>These features are all fully supported by GCC, MSVC, and clang. Below follows a table showing which version enables support for each feature respectively.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-305\" src=\"https:\/\/scionova.evdy.se\/wp-content\/uploads\/2018\/08\/full-300x80.png\" alt=\"\" width=\"773\" height=\"206\" srcset=\"https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/full-300x80.png 300w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/full-768x206.png 768w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/full-1024x274.png 1024w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/full.png 1248w\" sizes=\"(max-width: 773px) 100vw, 773px\" \/><\/p>\n<p>For more a detailed matrix with more compilers and all features of C++17 listed, follow this <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/compiler_support\">link<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Endnote<\/strong><\/p>\n<p>This was the last part of the series &#8220;6 Useful New Features in C++17&#8221; and I hope you found it helpful and interesting. All the previous blog posts in this series you will find under &#8220;<a href=\"https:\/\/scionova.evdy.se\/news\/\">NEWS<\/a>&#8220;.<\/p>\n<p>Don&#8217;t hesitate to share with your friends and colleagues and stay tuned for more!<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-342\" src=\"https:\/\/scionova.evdy.se\/wp-content\/uploads\/2018\/08\/Patrik.3-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/Patrik.3-225x300.jpg 225w, https:\/\/www.scionova.com\/wp-content\/uploads\/2018\/08\/Patrik.3-768x1024.jpg 768w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/>\u00a0\/\/Patrik Ingmarsson, Software Developer<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Constexpr lambdas Since C++11 we are able to use the constexpr specifier which evaluates the expression at compile time, with C++17 lambdas can also be constant expressions. One use case could be to initialize constexpr variables that depend on other constexpr variables. See the following example: This example maybe is silly but imagine a much [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":""},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/posts\/309"}],"collection":[{"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/comments?post=309"}],"version-history":[{"count":0,"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/posts\/309\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/media?parent=309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/categories?post=309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scionova.com\/en\/wp-json\/wp\/v2\/tags?post=309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}