{"id":1658,"date":"2017-10-27T01:00:42","date_gmt":"2017-10-27T01:00:42","guid":{"rendered":"https:\/\/www.fluentcpp.com\/?p=1658"},"modified":"2017-10-29T00:41:22","modified_gmt":"2017-10-29T00:41:22","slug":"function-aliases-cpp","status":"publish","type":"post","link":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/","title":{"rendered":"Function Aliases In C++"},"content":{"rendered":"<p><a href=\"https:\/\/www.fluentcpp.com\/dailycpp\/\"><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1947 size-full\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png?resize=120%2C116&#038;ssl=1\" alt=\"Daily C++\" width=\"120\" height=\"116\" \/><\/a><\/p>\n<p>One thing that dramatically improves the expressiveness of a piece of code is <a href=\"https:\/\/www.fluentcpp.com\/2016\/12\/15\/respect-levels-of-abstraction\/\" target=\"_blank\" rel=\"noopener\">respecting its levels of abstractions<\/a>.<\/p>\n<p>It sometimes involves massive refactorings, but in many cases it just comes down to <a href=\"https:\/\/www.fluentcpp.com\/2017\/01\/30\/how-to-choose-good-names\/\" target=\"_blank\" rel=\"noopener\">choosing good names in your code<\/a>. Picking a name that is consistent with the abstraction level of the surrounding code can make a difference between making a reader scratch their head and making them&#8230; read on.<\/p>\n<p>For this reason, today I&#8217;d like to share with you a feature made usable by C++11, that I think didn&#8217;t get as much credit as it deserves:<strong>\u00a0function aliases<\/strong>.<\/p>\n<h3><span style=\"color: #ff6600;\">C++03: one-liners<\/span><\/h3>\n<p>Can you see a case where it&#8217;s useful to define a function that has <strong>just one line of code<\/strong>? And what if that line is just forwarding the parameters to another function?<\/p>\n<pre class=\"lang:c++ decode:true\">int f(int parameter)\r\n{\r\n    return g(parameter);\r\n}<\/pre>\n<p>This seems pointless: why not call <code>g<\/code> directly, instead of calling <code>f<\/code>?<\/p>\n<p>In fact this can be useful, in the case where the name of <code>g<\/code> isn&#8217;t meaningful in the call site. Introducing <code>f<\/code>\u00a0gives your call site a way to read&#8221;\u00a0<code>f<\/code>&#8221; instead of &#8220;<code>g<\/code>&#8220;.<\/p>\n<p>Also, it decouples the call site from <code>g<\/code>, which becomes useful if we want to replace <code>g<\/code>\u00a0with something else and there are multiple places in the code where it was called. When you use <code>f<\/code> you only need to change it at one place: inside\u00a0<code>f<\/code>.<\/p>\n<p>Here is an example, adapted from the excellent book <a href=\"https:\/\/www.amazon.com\/gp\/product\/0735619670\/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0735619670&amp;linkCode=as2&amp;tag=fluentcpp-20&amp;linkId=d5740a1b637d19f7324be8302bc12b6b\">Code Complete<\/a> from Steve McConnell. Let&#8217;s take a function that generates a new Id. It happens that right now, this Id is generated by the database. But this could change in the future. So if we have a function <code>newIdFromDatabase()<\/code>\u00a0it would be worth considering wrapping it into another function, that only mention that we&#8217;re getting a new Id:<\/p>\n<pre class=\"lang:c++ decode:true \">int newId()\r\n{\r\n    return newIdFromDatabase();\r\n}<\/pre>\n<p>This way:<\/p>\n<ul>\n<li>we could redirect <code>newId<\/code>\u00a0to something else without changing all the places that use it,<\/li>\n<li>the calling code does not read any mention of the database, which makes it that much clearer because it keeps this lower level of abstraction hidden.<\/li>\n<\/ul>\n<p>However, this approach also presents several drawbacks:<\/p>\n<ul>\n<li>it could make extra copies if ever the function is not inlined,<\/li>\n<li>it can take an annoying amount of code if there are several parameters to be passed down to the low-level function,<\/li>\n<li>when debugging, it&#8217;s an extra step you need to step through.<\/li>\n<\/ul>\n<p>This is where<strong>\u00a0function aliases<\/strong> come into play.<\/p>\n<h3><span style=\"color: #ff6600;\">C++11: function aliases<\/span><\/h3>\n<p>C++11 provides another approach for this:<\/p>\n<pre class=\"lang:c++ decode:true\">const auto newId = newIdFromDatabase;<\/pre>\n<p>This solves most of the above drawbacks: it makes no extra copy, since calling <code>newId<\/code>\u00a0is calling <code>newIdFromDatabase<\/code>, and the declaration is quite straightforward.<\/p>\n<p>EDIT: Note the <code>const<\/code>! As Stephan T. Lavavej pointed out, having a bare\u00a0<code>auto newId = newIdFromDatabase<\/code>\u00a0would be dangerous because the function pointer <code>newId<\/code>\u00a0could be changed and point to something else. It would be like a global variable, but in the form of a function. Very complex and bug-prone.<\/p>\n<p>Here, <code>newId<\/code>\u00a0was a function pointer. We could also define it a function reference:<\/p>\n<pre class=\"lang:c++ decode:true \">auto&amp; newId = newIdFromDatabase;<\/pre>\n<p>In this case we no longer needs a <code>const<\/code>\u00a0because this function reference, like all references, can&#8217;t be reassigned. But the resulting declaration looks a bit weird.\u00a0A big thank you to Stephan for those observations.<\/p>\n<p>Note that you don&#8217;t even need to have the full definition of <code>newIdFromDatabase<\/code>\u00a0available at the point of the function alias declaration. Only its\u00a0<strong>declaration<\/strong>\u00a0needs to be visible from it. Indeed, the actual resolution is made by the linker, like with any other function.<\/p>\n<p>EDIT: Note that <code>newId<\/code>\u00a0is not strictly a <em>function alias<\/em> since there is no such thing in C++, but a function pointer that semantically plays the role of an alias here.<\/p>\n<p>Let&#8217;s mention that C++98 could achieve an roughly equivalent result, as it could manipulate functions:<\/p>\n<pre class=\"lang:c++ decode:true\">typedef int (&amp;IdFunction)();\r\nIdFunction newId = newIdFromDatabase;<\/pre>\n<p>But the syntax was really not natural to read, and you can imagine that it doesn&#8217;t get better when there are more arguments. The real new feature that enables practical function aliasing here is <code>auto<\/code>.<\/p>\n<p>Note that while one-liners added an extra step in debugging, this approach kind of removes one step. Indeed, when you step in <code>newId<\/code>\u00a0at call site, you directly fall into <code>newIdFromDatabase<\/code>\u00a0and you don&#8217;t even see <code>newId<\/code>\u00a0in the call stack. This can be disturbing. Another drawback is that since <code>newId<\/code>\u00a0is a function reference, it will not be inlined.<\/p>\n<h3><span style=\"color: #ff6600;\">C++14: template function aliases<\/span><\/h3>\n<p>What if we want to alias a template function?<\/p>\n<pre class=\"lang:c++ decode:true\">template&lt;typename T&gt;\r\nvoid g(T)\r\n{\r\n}<\/pre>\n<p>Can we just write:<\/p>\n<pre class=\"lang:c++ decode:true\">template&lt;typename T&gt;\r\nconst auto f = g&lt;T&gt;;<\/pre>\n<p>In C++11 no. In C++14, yes.<\/p>\n<p>The feature of C++14 that enables to do this is <strong>variable templates<\/strong>. Indeed, in C++98 only types and functions could be templates. C++11 allowed using declarations to be template too, and C++14 allows values to be templates. Those are called variable templates.<\/p>\n<h4><span style=\"color: #ff6600;\">Type deduction didn&#8217;t follow<\/span><\/h4>\n<p>In C++, template functions operate a deduction on the type of their parameters. For example, with the following call:<\/p>\n<pre class=\"lang:c++ decode:true \">g(42);<\/pre>\n<p>we don&#8217;t need to specify that <code>T<\/code>\u00a0is <code>int<\/code>. The compiler deduces it automatically. Read Item 1 of <a href=\"https:\/\/www.amazon.com\/gp\/product\/1491903996\/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1491903996&amp;linkCode=as2&amp;tag=fluentcpp-20&amp;linkId=c3922df74051882502a2d72f2e0e7f28\" target=\"_blank\" rel=\"noopener\">Effective Modern C++<\/a> to know exactly how that deduction works.<\/p>\n<p>But the thing is, template functions aliases don&#8217;t do type deduction. So to call them you need to specify the template types explicitly, even if the parameters carry all the necessary information to deduce them:<\/p>\n<pre class=\"lang:c++ decode:true\">f&lt;int&gt;(42);<\/pre>\n<p>This seems like a serious limitation to me (imagine how it would look like on something equivalent to an STL algorithm?), since it hinders readability and it was one of the main advantages we mentioned at the beginning of this article.<\/p>\n<p>There is a workaround to this. I can&#8217;t say I like it very much but let&#8217;s put it for the sake of comprehensiveness. It consists in using a macro to generate the wrapping function:<\/p>\n<pre class=\"lang:c++ decode:true \">#define ALIAS_TEMPLATE_FUNCTION(highLevelF, lowLevelF) \\\r\ntemplate&lt;typename... Args&gt; \\\r\ninline auto highLevelF(Args&amp;&amp;... args) -&gt; decltype(lowLevelF(std::forward&lt;Args&gt;(args)...)) \\\r\n{ \\\r\n    return lowLevelF(std::forward&lt;Args&gt;(args)...); \\\r\n}<\/pre>\n<p>You can then define the &#8220;alias&#8221;:<\/p>\n<pre class=\"lang:c++ decode:true \">ALIAS_TEMPLATE_FUNCTION(f, g)<\/pre>\n<p>and since it creates a normal template function, type deduction works normally:<\/p>\n<pre class=\"lang:c++ decode:true \">f(42);<\/pre>\n<p>And it also has the advantage of preserving the possibility to inline the code inside the lower level function.<\/p>\n<h3><span style=\"color: #ff6600;\">EDIT: Security<\/span><\/h3>\n<p>Stephan also pointed out a downside of function pointers: long-lived function pointers can be a target for security exploits.<\/p>\n<p>My understanding of this exploit is that if a malevolant agent can figure out the value of that pointer, then they would know a memory address that the application is likely to call. They could then replace the code at that address any code, and have it executed. Microsoft uses\u00a0<a href=\"https:\/\/msdn.microsoft.com\/fr-fr\/library\/bb432254(v=vs.85).aspx\" target=\"_blank\" rel=\"noopener\">EncodePointer<\/a> to protect function pointers and prevent this kind of attack.<\/p>\n<h3><span style=\"color: #ff6600;\">Aliasing, aliasing, aliasing<\/span><\/h3>\n<p>I&#8217;ve presented the different ways I know to alias a function in C++, with their advantages and drawbacks. Don&#8217;t hesitate to put a comment if you see something missing in this presentation.<\/p>\nDon't want to miss out ? <strong>Follow:<\/strong> &nbsp&nbsp<a class=\"synved-social-button synved-social-button-follow synved-social-size-48 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Follow me on twitter\" href=\"https:\/\/twitter.com\/joboccara\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Follow me on twitter\" class=\"synved-share-image synved-social-image synved-social-image-follow\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/twitter.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-follow synved-social-size-48 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Find us on Linkedin\" href=\"https:\/\/www.linkedin.com\/in\/jonathan-boccara-23826921\/\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Find us on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-follow\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/linkedin.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-follow synved-social-size-48 synved-social-resolution-single synved-social-provider-rss nolightbox\" data-provider=\"rss\" target=\"_blank\" rel=\"nofollow\" title=\"Subscribe to our RSS Feed\" href=\"https:\/\/www.fluentcpp.com\/feed\/\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"rss\" title=\"Subscribe to our RSS Feed\" class=\"synved-share-image synved-social-image synved-social-image-follow\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/rss.png?resize=48%2C48&#038;ssl=1\" \/><\/a><br\/>Share this post!<a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Check out this post from Fluent C++\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.fluentcpp.com%2Fwp-json%2Fwp%2Fv2%2Fposts%2F1658&#038;t=Function%20Aliases%20In%20C%2B%2B&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.fluentcpp.com%2Fwp-json%2Fwp%2Fv2%2Fposts%2F1658&#038;p&#091;images&#093;&#091;0&#093;=https%3A%2F%2Fwww.fluentcpp.com%2Fwp-content%2Fuploads%2F2017%2F09%2Fdaily-able-content-e1505330890615.png&#038;p&#091;title&#093;=Function%20Aliases%20In%20C%2B%2B\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Check out this post from Fluent C++\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/facebook.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Tweet about this\" href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.fluentcpp.com%2Fwp-json%2Fwp%2Fv2%2Fposts%2F1658&#038;text=Check%20out%20this%20post%20from%20Fluent%20C%2B%2B\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Tweet about this\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/twitter.png?resize=48%2C48&#038;ssl=1\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.fluentcpp.com%2Fwp-json%2Fwp%2Fv2%2Fposts%2F1658&#038;title=Function%20Aliases%20In%20C%2B%2B\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/linkedin.png?resize=48%2C48&#038;ssl=1\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>One thing that dramatically improves the expressiveness of a piece of code is respecting its levels of abstractions. It sometimes involves massive refactorings, but in many cases it just comes down to choosing good names in your code. Picking a name that is consistent with the abstraction level of the surrounding code can make a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[252,10,16,253,85],"class_list":["post-1658","post","type-post","status-publish","format-standard","hentry","category-expressive-code","tag-alias","tag-c","tag-expressive","tag-functions","tag-template"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Function Aliases In C++ - Fluent C++<\/title>\n<meta name=\"description\" content=\"Function aliases are a way to use better names in your code, and to have a better decoupling between functionalities. Here is how to achieve this in C++\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Function Aliases In C++ - Fluent C++\" \/>\n<meta property=\"og:description\" content=\"Function aliases are a way to use better names in your code, and to have a better decoupling between functionalities. Here is how to achieve this in C++\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/\" \/>\n<meta property=\"og:site_name\" content=\"Fluent C++\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-27T01:00:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-29T00:41:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png\" \/>\n<meta name=\"author\" content=\"Jonathan Boccara\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@joboccara\" \/>\n<meta name=\"twitter:site\" content=\"@JoBoccara\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan Boccara\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/\"},\"author\":{\"name\":\"Jonathan Boccara\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/#\\\/schema\\\/person\\\/bc2586443e40d356676d1b1740521237\"},\"headline\":\"Function Aliases In C++\",\"datePublished\":\"2017-10-27T01:00:42+00:00\",\"dateModified\":\"2017-10-29T00:41:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/\"},\"wordCount\":1085,\"commentCount\":10,\"image\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fluentcpp.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/daily-able-content-e1505330890615.png\",\"keywords\":[\"alias\",\"C++\",\"expressive\",\"functions\",\"template\"],\"articleSection\":[\"Expressive code\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/\",\"url\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/\",\"name\":\"Function Aliases In C++ - Fluent C++\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fluentcpp.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/daily-able-content-e1505330890615.png\",\"datePublished\":\"2017-10-27T01:00:42+00:00\",\"dateModified\":\"2017-10-29T00:41:22+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/#\\\/schema\\\/person\\\/bc2586443e40d356676d1b1740521237\"},\"description\":\"Function aliases are a way to use better names in your code, and to have a better decoupling between functionalities. Here is how to achieve this in C++\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.fluentcpp.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/daily-able-content-e1505330890615.png?fit=120%2C116&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.fluentcpp.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/daily-able-content-e1505330890615.png?fit=120%2C116&ssl=1\",\"width\":120,\"height\":116,\"caption\":\"Daily C++\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/2017\\\/10\\\/27\\\/function-aliases-cpp\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.fluentcpp.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Function Aliases In C++\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/#website\",\"url\":\"https:\\\/\\\/www.fluentcpp.com\\\/\",\"name\":\"Fluent C++\",\"description\":\"Jonathan Boccara&#039;s blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.fluentcpp.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.fluentcpp.com\\\/#\\\/schema\\\/person\\\/bc2586443e40d356676d1b1740521237\",\"name\":\"Jonathan Boccara\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf2136ea15306047a4aa549b5400deb87e750440abe9f5fab5ea5d8b47349d27?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf2136ea15306047a4aa549b5400deb87e750440abe9f5fab5ea5d8b47349d27?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf2136ea15306047a4aa549b5400deb87e750440abe9f5fab5ea5d8b47349d27?s=96&d=mm&r=g\",\"caption\":\"Jonathan Boccara\"},\"description\":\"Hello, my name is Jonathan Boccara, I'm your host on Fluent C++. I have been a developer for 14 years. My focus is on how to write expressive code. I wrote the book The Legacy Code Programmer's Toolbox. I'm happy to take your feedback, don't hesitate to drop a comment on a post, follow me or get in touch directly !\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/jonathan-boccara-23826921\\\/\",\"https:\\\/\\\/x.com\\\/joboccara\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Function Aliases In C++ - Fluent C++","description":"Function aliases are a way to use better names in your code, and to have a better decoupling between functionalities. Here is how to achieve this in C++","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/","og_locale":"en_US","og_type":"article","og_title":"Function Aliases In C++ - Fluent C++","og_description":"Function aliases are a way to use better names in your code, and to have a better decoupling between functionalities. Here is how to achieve this in C++","og_url":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/","og_site_name":"Fluent C++","article_published_time":"2017-10-27T01:00:42+00:00","article_modified_time":"2017-10-29T00:41:22+00:00","og_image":[{"url":"https:\/\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png","type":"","width":"","height":""}],"author":"Jonathan Boccara","twitter_card":"summary_large_image","twitter_creator":"@joboccara","twitter_site":"@JoBoccara","twitter_misc":{"Written by":"Jonathan Boccara","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#article","isPartOf":{"@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/"},"author":{"name":"Jonathan Boccara","@id":"https:\/\/www.fluentcpp.com\/#\/schema\/person\/bc2586443e40d356676d1b1740521237"},"headline":"Function Aliases In C++","datePublished":"2017-10-27T01:00:42+00:00","dateModified":"2017-10-29T00:41:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/"},"wordCount":1085,"commentCount":10,"image":{"@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png","keywords":["alias","C++","expressive","functions","template"],"articleSection":["Expressive code"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/","url":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/","name":"Function Aliases In C++ - Fluent C++","isPartOf":{"@id":"https:\/\/www.fluentcpp.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#primaryimage"},"image":{"@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png","datePublished":"2017-10-27T01:00:42+00:00","dateModified":"2017-10-29T00:41:22+00:00","author":{"@id":"https:\/\/www.fluentcpp.com\/#\/schema\/person\/bc2586443e40d356676d1b1740521237"},"description":"Function aliases are a way to use better names in your code, and to have a better decoupling between functionalities. Here is how to achieve this in C++","breadcrumb":{"@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#primaryimage","url":"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png?fit=120%2C116&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.fluentcpp.com\/wp-content\/uploads\/2017\/09\/daily-able-content-e1505330890615.png?fit=120%2C116&ssl=1","width":120,"height":116,"caption":"Daily C++"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fluentcpp.com\/2017\/10\/27\/function-aliases-cpp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fluentcpp.com\/"},{"@type":"ListItem","position":2,"name":"Function Aliases In C++"}]},{"@type":"WebSite","@id":"https:\/\/www.fluentcpp.com\/#website","url":"https:\/\/www.fluentcpp.com\/","name":"Fluent C++","description":"Jonathan Boccara&#039;s blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fluentcpp.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.fluentcpp.com\/#\/schema\/person\/bc2586443e40d356676d1b1740521237","name":"Jonathan Boccara","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf2136ea15306047a4aa549b5400deb87e750440abe9f5fab5ea5d8b47349d27?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf2136ea15306047a4aa549b5400deb87e750440abe9f5fab5ea5d8b47349d27?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf2136ea15306047a4aa549b5400deb87e750440abe9f5fab5ea5d8b47349d27?s=96&d=mm&r=g","caption":"Jonathan Boccara"},"description":"Hello, my name is Jonathan Boccara, I'm your host on Fluent C++. I have been a developer for 14 years. My focus is on how to write expressive code. I wrote the book The Legacy Code Programmer's Toolbox. I'm happy to take your feedback, don't hesitate to drop a comment on a post, follow me or get in touch directly !","sameAs":["https:\/\/www.linkedin.com\/in\/jonathan-boccara-23826921\/","https:\/\/x.com\/joboccara"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/posts\/1658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/comments?post=1658"}],"version-history":[{"count":18,"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/posts\/1658\/revisions"}],"predecessor-version":[{"id":2502,"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/posts\/1658\/revisions\/2502"}],"wp:attachment":[{"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/media?parent=1658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/categories?post=1658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fluentcpp.com\/wp-json\/wp\/v2\/tags?post=1658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}