{"id":6138,"date":"2021-05-13T08:20:37","date_gmt":"2021-05-13T08:20:37","guid":{"rendered":"https:\/\/www.modernescpp.com\/index.php\/function-templates-more-details\/"},"modified":"2021-05-13T08:20:37","modified_gmt":"2021-05-13T08:20:37","slug":"function-templates-more-details","status":"publish","type":"post","link":"https:\/\/www.modernescpp.com\/index.php\/function-templates-more-details\/","title":{"rendered":"Function Templates &#8211; More Details about Explicit Template Arguments and Concepts"},"content":{"rendered":"<p>In the last post, &#8220;<a href=\"https:\/\/www.modernescpp.com\/index.php\/function-templates\">Function Templates<\/a>&#8220;, I wrote about the overloading of function templates and automatically deducing the return type of a function template. Today, I dive deeper and explicitly specify a function template&#8217;s arguments and bring concepts into the play.<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6127\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/templatesNew.png\" alt=\"templatesNew\" width=\"650\" height=\"396\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/templatesNew.png 902w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/templatesNew-300x183.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/templatesNew-768x468.png 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>Before I start this post, I have to make two general remarks. Today, I write about a don&#8217;t and a do.<\/p>\n<ul>\n<li><strong>Don&#8217;t: In general, you should not explicitly specify the template arguments for function templates. <\/strong><\/li>\n<li><strong>Do: You should generally use restricted template parameters (concepts).<\/strong><\/li>\n<\/ul>\n<p>Let me start with the don&#8217;t.<\/p>\n<h2>Explicitly Specifying the Template Arguments<\/h2>\n<p>You can explicitly specify the template arguments. This is necessary if the compiler cannot deduce the type parameters of the function templates or if you use class templates. With C++17, the compiler can automatically deduce the type of the template arguments from the constructor arguments:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\">std<span style=\"color: #555555;\">::<\/span>vector<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span><span style=\"color: #555555;\">&gt;<\/span> myVec{<span style=\"color: #ff6600;\">1<\/span>, <span style=\"color: #ff6600;\">2<\/span>, <span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>, <span style=\"color: #ff6600;\">5<\/span>};  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)<\/span>\r\nstd<span style=\"color: #555555;\">::<\/span>vector myVec{<span style=\"color: #ff6600;\">1<\/span>, <span style=\"color: #ff6600;\">2<\/span>, <span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>, <span style=\"color: #ff6600;\">5<\/span>};       <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\r\n<\/pre>\n<\/div>\n<p>Instead of line (1), you can use line (2) in C++17. I will write more about this feature in an upcoming post.<\/p>\n<p>Once more. In general, you should not specify the template arguments. But I intentionally did it.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ maxExplicitTypeParameter.cpp<\/span>\r\n\r\n<span style=\"color: #006699; font-weight: bold;\">template<\/span> <span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #006699; font-weight: bold;\">typename<\/span> T<span style=\"color: #555555;\">&gt;<\/span>\r\nT max(<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> lhs,<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> rhs) {\r\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> (lhs <span style=\"color: #555555;\">&gt;<\/span> rhs)<span style=\"color: #555555;\">?<\/span> lhs <span style=\"color: #555555;\">:<\/span> rhs;\r\n}\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> main() {\r\n  \r\n  <span style=\"color: #006699; font-weight: bold;\">auto<\/span> res1 <span style=\"color: #555555;\">=<\/span> max<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">float<\/span><span style=\"color: #555555;\">&gt;<\/span>(<span style=\"color: #ff6600;\">5.5<\/span>, <span style=\"color: #ff6600;\">6.0<\/span>);\r\n  <span style=\"color: #006699; font-weight: bold;\">auto<\/span> res2 <span style=\"color: #555555;\">=<\/span> max<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">bool<\/span><span style=\"color: #555555;\">&gt;<\/span>(<span style=\"color: #ff6600;\">5.5<\/span>, <span style=\"color: #ff6600;\">6.0<\/span>);\r\n  <span style=\"color: #006699; font-weight: bold;\">auto<\/span> res3 <span style=\"color: #555555;\">=<\/span> max(<span style=\"color: #ff6600;\">5.5<\/span>, <span style=\"color: #ff6600;\">6.0<\/span>);\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>&nbsp;What is happening in lines (1) &#8211; (3)? <a href=\"https:\/\/cppinsights.io\/lnk?code=Ly8gbWF4RXhwbGljaXRUeXBlUGFyYW1ldGVyLmNwcAoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+ClQgbWF4KFQgbGhzLFQgcmhzKSB7CiAgICByZXR1cm4gKGxocyA+IHJocyk\/IGxocyA6IHJoczsKfQoKaW50IG1haW4oKSB7CiAgCiAgYXV0byByZXMxID0gbWF4PGZsb2F0Pig1LjUsIDYuMCk7CiAgYXV0byByZXN0MiA9IG1heDxib29sPig1LjUsIDYuMCk7CiAgYXV0byByZXMzID0gbWF4KDUuNSwgNi4wKTsKICAKfQ==&amp;insightsOptions=cpp11&amp;std=cpp11&amp;rev=1.0\">C++ Insights <\/a>helps me to analyze the code. These are the crucial output lines:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6135\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxExplicitInstantiationCppInsightsNew.png\" alt=\"maxExplicitInstantiationCppInsightsNew\" width=\"650\" height=\"610\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxExplicitInstantiationCppInsightsNew.png 783w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxExplicitInstantiationCppInsightsNew-300x282.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxExplicitInstantiationCppInsightsNew-768x721.png 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>The call <code>max&lt;float&gt;(5.5, 6.0)<\/code> in line (1) causes the instantiation of the function template <code>max<\/code> for <code>double<\/code> (line 10). Consequently, both doubles are converted to <code>const float<\/code> (line 40).&nbsp;<\/li>\n<li>The call <code>max&lt;bool&gt;(5.5,&nbsp; 6.0) <\/code>in line (2) puts a lot of work on the compiler&#8217;s shoulder.&nbsp;\n<ol>\n<li>The invocation causes the compiler to convert the doubles to implicitly <code>bool.<\/code><\/li>\n<li>To compare both bools inside the function body (line 23), they must be promoted to <code>int<\/code> (line 23).<\/li>\n<li>Finally, the return type <code>res2<\/code> is bool. Consequently, the <code>int<\/code> must be converted to <code>bool<\/code>.<\/li>\n<\/ol>\n<\/li>\n<li>The call<code> max(5.5, 6.0)<\/code>&nbsp; in line (3) does precisely the job you want. No conversion or promotion is necessary.<\/li>\n<\/ul>\n<p>Honestly, I would consider the <code>max&lt;bool&gt;(5.5, 6.0)<\/code> as an error and not intentional. But this happens when you want to be brighter than the compiler.<\/p>\n<p>There is a related syntax to the explicit specification of template arguments that you may sometimes see but puzzles you: <code>max&lt;&gt;(5.5, 6.0); <\/code>When do I ask in my seminars: What could that mean? Based on the previous theory, half of my participants would guess it right<\/p>\n<p>Imagine you have a function and a function template <code>max<\/code>:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ maxCompilerDeduction.cpp<\/span>\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">double<\/span> <span style=\"color: #cc00ff;\">max<\/span>(<span style=\"color: #006699; font-weight: bold;\">const<\/span> <span style=\"color: #007788; font-weight: bold;\">double<\/span><span style=\"color: #555555;\">&amp;<\/span> lhs, <span style=\"color: #006699; font-weight: bold;\">const<\/span> <span style=\"color: #007788; font-weight: bold;\">double<\/span><span style=\"color: #555555;\">&amp;<\/span> rhs) {\r\n  <span style=\"color: #006699; font-weight: bold;\">return<\/span> (lhs <span style=\"color: #555555;\">&gt;<\/span> rhs)<span style=\"color: #555555;\">?<\/span> lhs <span style=\"color: #555555;\">:<\/span> rhs;\r\n}\r\n\r\n<span style=\"color: #006699; font-weight: bold;\">template<\/span> <span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #006699; font-weight: bold;\">typename<\/span> T<span style=\"color: #555555;\">&gt;<\/span>\r\nT max(<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> lhs,<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> rhs) {\r\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> (lhs <span style=\"color: #555555;\">&gt;<\/span> rhs)<span style=\"color: #555555;\">?<\/span> lhs <span style=\"color: #555555;\">:<\/span> rhs;\r\n}\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> main() {\r\n  \r\n  <span style=\"color: #006699; font-weight: bold;\">auto<\/span> res1 <span style=\"color: #555555;\">=<\/span> max(<span style=\"color: #ff6600;\">5.5<\/span>, <span style=\"color: #ff6600;\">6.0<\/span>);    <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)<\/span>\r\n  <span style=\"color: #006699; font-weight: bold;\">auto<\/span> res2 <span style=\"color: #555555;\">=<\/span> max<span style=\"color: #555555;\">&lt;&gt;<\/span>(<span style=\"color: #ff6600;\">5.5<\/span>, <span style=\"color: #ff6600;\">6.0<\/span>);  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>As we learned in the previous post, &#8220;<a href=\"https:\/\/www.modernescpp.com\/index.php\/function-templates\">Function Templates<\/a>&#8220;, the compiler prefers the function when the function and the function templates are ideal fits. Okay, this answers line (1). Line (2) expresses that the compiler should only consider the function template <code>max<\/code> and ignore the function <code>max<\/code>. Additionally, the compiler automatically deduces the template parameters for the function arguments. Consequently, <a href=\"https:\/\/cppinsights.io\/lnk?code=Ly8gbWF4Q29tcGlsZXJEZWR1Y3Rpb24uY3BwCgpkb3VibGUgbWF4KGNvbnN0IGRvdWJsZSYgbGhzLCBjb25zdCBkb3VibGUmIHJocykgewogIHJldHVybiAobGhzID4gcmhzKT8gbGhzIDogcmhzOwp9Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4KVCBtYXgoY29uc3QgVCYgbGhzLGNvbnN0IFQmIHJocykgewogICAgcmV0dXJuIChsaHMgPiByaHMpPyBsaHMgOiByaHM7Cn0KCmludCBtYWluKCkgewogIAogIGF1dG8gcmVzMSA9IG1heCg1LjUsIDYuMCk7CiAgYXV0byByZXMyID0gbWF4PD4oNS41LCA2LjApOwogIAp9&amp;insightsOptions=cpp11&amp;std=cpp11&amp;rev=1.0\">C++ Insights<\/a> shows that the compiler instantiated <code>max<\/code> for <code>double<\/code>.<\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6136\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxCompilerDeductionCppInsights.png\" alt=\"maxCompilerDeductionCppInsights\" width=\"450\" height=\"142\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxCompilerDeductionCppInsights.png 526w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxCompilerDeductionCppInsights-300x95.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/p>\n<p>So far, I have only considered function overloading with functions and function templates having unrestricted type parameters. Okay, I can do better and should. Now, I bring restricted type parameters (concepts) into the play. This means here is my do for this post: Use restricted type parameters if possible.<\/p>\n<\/p>\n<h2>Overloading with Concepts<\/h2>\n<p>C++20 has the concept <code>std::totally_ordered<\/code>. A type <code>T<\/code> supports a total order if it supports partial order and any elements of T can be compared. Let me be more formal:<\/p>\n<p>A type T supports <strong>partial order<\/strong> if the following relations for all elements a, b, and c of the type T hold:<\/p>\n<ol>\n<li>a &lt;= a (reflexive)<\/li>\n<li>If a &lt;= b and b &lt;= c then a &lt;= c (transitive)<\/li>\n<li>If a &lt;=b and b &lt;= a then a == b (antisymmetric)<\/li>\n<\/ol>\n<p>A type T supports <strong>total order<\/strong> if it supports partial order and all elements of T can be compared.<\/p>\n<ol>\n<li>a &lt;= b or b &lt;= b (comparable)<\/li>\n<\/ol>\n<p>The following program uses the concept<code> std::totally_ordered<\/code>:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ maxUnconstrainedConstrained.cpp<\/span>\r\n\r\n<span style=\"color: #009999;\">#include &lt;iostream&gt;<\/span>\r\n<span style=\"color: #009999;\">#include &lt;concepts&gt;<\/span>\r\n\r\n<span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">Account<\/span> {\r\n <span style=\"color: #9999ff;\">public:<\/span>\r\n    <span style=\"color: #006699; font-weight: bold;\">explicit<\/span> Account(<span style=\"color: #007788; font-weight: bold;\">double<\/span> b)<span style=\"color: #555555;\">:<\/span> balance(b) {}\r\n    <span style=\"color: #007788; font-weight: bold;\">double<\/span> getBalance() <span style=\"color: #006699; font-weight: bold;\">const<\/span> { \r\n        <span style=\"color: #006699; font-weight: bold;\">return<\/span> balance;\r\n    }\r\n <span style=\"color: #9999ff;\">private:<\/span>\r\n    <span style=\"color: #007788; font-weight: bold;\">double<\/span> balance;\r\n};\r\n  \r\nAccount <span style=\"color: #cc00ff;\">max<\/span>(<span style=\"color: #006699; font-weight: bold;\">const<\/span> Account<span style=\"color: #555555;\">&amp;<\/span> lhs, <span style=\"color: #006699; font-weight: bold;\">const<\/span> Account<span style=\"color: #555555;\">&amp;<\/span> rhs) {  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)<\/span>\r\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"max function<\/span><span style=\"color: #cc3300; font-weight: bold;\">\\n<\/span><span style=\"color: #cc3300;\">\"<\/span>;\r\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> (lhs.getBalance() <span style=\"color: #555555;\">&gt;<\/span> rhs.getBalance())<span style=\"color: #555555;\">?<\/span> lhs <span style=\"color: #555555;\">:<\/span> rhs;\r\n}\r\n\r\n<span style=\"color: #006699; font-weight: bold;\">template<\/span> <span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>totally_ordered T<span style=\"color: #555555;\">&gt;<\/span>                       <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\r\nT max(<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> lhs,<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> rhs) {                     \r\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"max restricted function template<\/span><span style=\"color: #cc3300; font-weight: bold;\">\\n<\/span><span style=\"color: #cc3300;\">\"<\/span>;\r\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> (lhs <span style=\"color: #555555;\">&gt;<\/span> rhs)<span style=\"color: #555555;\">?<\/span> lhs <span style=\"color: #555555;\">:<\/span> rhs;\r\n}\r\n\r\n<span style=\"color: #006699; font-weight: bold;\">template<\/span> <span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #006699; font-weight: bold;\">typename<\/span> T<span style=\"color: #555555;\">&gt;<\/span>                                   <span style=\"color: #0099ff; font-style: italic;\">\/\/ (3)<\/span>\r\nT max(<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> lhs,<span style=\"color: #006699; font-weight: bold;\">const<\/span> T<span style=\"color: #555555;\">&amp;<\/span> rhs) {                   \r\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"max unrestriced function template<\/span><span style=\"color: #cc3300; font-weight: bold;\">\\n<\/span><span style=\"color: #cc3300;\">\"<\/span>;\r\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> (lhs <span style=\"color: #555555;\">&gt;<\/span> rhs)<span style=\"color: #555555;\">?<\/span> lhs <span style=\"color: #555555;\">:<\/span> rhs;\r\n}\r\n\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> main() {\r\n  \r\n    Account account1(<span style=\"color: #ff6600;\">50.5<\/span>);\r\n    Account <span style=\"color: #cc00ff;\">account2<\/span>(<span style=\"color: #ff6600;\">60.5<\/span>);\r\n    Account maxAccount <span style=\"color: #555555;\">=<\/span> max(account1, account2);       <span style=\"color: #0099ff; font-style: italic;\">\/\/ (4)<\/span>\r\n  \r\n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> i1{<span style=\"color: #ff6600;\">50<\/span>};\r\n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">i2<\/span>(<span style=\"color: #ff6600;\">60<\/span>);\r\n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> maxI <span style=\"color: #555555;\">=<\/span> max(i2, i2);                             <span style=\"color: #0099ff; font-style: italic;\">\/\/ (5)<\/span>\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>The program defines a function <code>max<\/code> taking two Accounts (line 1) and two function templates. The first function template <code>max<\/code> in line (2) requires that the values support a total ordering. The second function template <code>max<\/code> has no type constraints on its type parameters. As you might expect, the compiler chooses the best-fitting overload. A function template a fits better than another function template b if a is more specialized than b. This means it chooses the function for Accounts (line 4) and the function template <code>max<\/code> with restricted type parameters for <code>int<\/code> (line 5).<\/p>\n<p>The comments in the various <code>max<\/code> function make the decisions of the compiler transparent.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6137\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxCompilerExplorer.png\" alt=\"maxCompilerExplorer\" width=\"300\" height=\"56\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxCompilerExplorer.png 399w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/05\/maxCompilerExplorer-300x56.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>You can study the program on <a href=\"https:\/\/godbolt.org\/z\/4ThvMqbz4\">Compiler Explorer<\/a>.<\/p>\n<h2>What&#8217;s next?<\/h2>\n<p>After the basics to function templates, I will present the basics of class templates in my next post. Additionally, I will write in this context about generic member functions, inheritance with templates, and alias templates.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"simple-translate\">\n<div>\n<div class=\"simple-translate-button isShow\" style=\"background-image: url('moz-extension:\/\/03d76dbb-fb01-4e7f-abc2-63464d70adc9\/icons\/512.png'); height: 22px; width: 22px; top: 13px; left: 3px;\">&nbsp;<\/div>\n<div class=\"simple-translate-panel\" style=\"width: 300px; height: 200px; top: 0px; left: 0px; font-size: 13px; background-color: #ffffff;\">\n<div class=\"simple-translate-result-wrapper\" style=\"overflow: hidden;\">\n<div class=\"simple-translate-move\" draggable=\"draggable\">&nbsp;<\/div>\n<div class=\"simple-translate-result-contents\">\n<p class=\"simple-translate-result\" dir=\"auto\" style=\"color: #000000;\">&nbsp;<\/p>\n<p class=\"simple-translate-candidate\" dir=\"auto\" style=\"color: #737373;\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the last post, &#8220;Function Templates&#8220;, I wrote about the overloading of function templates and automatically deducing the return type of a function template. Today, I dive deeper and explicitly specify a function template&#8217;s arguments and bring concepts into the play.<\/p>\n","protected":false},"author":21,"featured_media":6127,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[376],"tags":[],"class_list":["post-6138","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-templates"],"_links":{"self":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/comments?post=6138"}],"version-history":[{"count":0,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media\/6127"}],"wp:attachment":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=6138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=6138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=6138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}