{"id":2055,"date":"2025-01-27T19:36:29","date_gmt":"2025-01-27T19:36:29","guid":{"rendered":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/?page_id=2055"},"modified":"2025-01-27T21:16:47","modified_gmt":"2025-01-27T21:16:47","slug":"template-explicit-specialization","status":"publish","type":"page","link":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/topics\/c-details\/function-templates-2\/template-explicit-specialization\/","title":{"rendered":"Template Explicit Specialization"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Template_Explicit_Specialization\"><\/span>Template Explicit Specialization<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let&#8217;s look at a simpler template function, one that returns whether the first value is greater than the second value:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  templcompare.h\n\/\/  Function Templates\n\/\/\n\/\/  Created by Bryan Higgs on 10\/11\/24.\n\/\/\n\n#ifndef templcompare_h\n#define templcompare_h\n\ntemplate &lt;typename T&gt;\nbool isGreater(const T &amp;value1, const T &amp;value2)\n{\n  if (value1 &gt; value2)\n    return true;\n  return false;\n}\n\n#endif \/* templcompare_h *\/\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  templcompare.h<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Function Templates<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/11\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#ifndef<\/span><span style=\"color: #0000FF\"> templcompare_h<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#define<\/span><span style=\"color: #0000FF\"> templcompare_h<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">bool<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">&amp;<\/span><span style=\"color: #001080\">value1<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">&amp;<\/span><span style=\"color: #001080\">value2<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> (value1 &gt; value2)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">false<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#endif<\/span><span style=\"color: #008000\"> \/* templcompare_h *\/<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  templcompare_main.cpp\n\/\/  Function Templates\n\/\/\n\/\/  Created by Bryan Higgs on 10\/11\/24.\n\/\/\n\n#include &lt;iostream&gt;\n#include &quot;templcompare.h&quot;\n\nint main(int argc, const char * argv[])\n{\n  int i1 = 5, i2 = 2;\n  double d1 = 45.2, d2 = 89.3;\n  const char *s1 = &quot;Frodo&quot;, *s2 = &quot;Bilbo&quot;;\n  \n  std::cout &lt;&lt; i1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; i2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(i1, i2) &lt;&lt; std::endl;\n  std::cout &lt;&lt; d1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; d2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(d1, d2) &lt;&lt; std::endl;\n  std::cout &lt;&lt; s1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; s2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(s1, s2) &lt;&lt; std::endl;\n  \n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  templcompare_main.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Function Templates<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/11\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&quot;templcompare.h&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> i1 = <\/span><span style=\"color: #098658\">5<\/span><span style=\"color: #000000\">, i2 = <\/span><span style=\"color: #098658\">2<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\"> d1 = <\/span><span style=\"color: #098658\">45.2<\/span><span style=\"color: #000000\">, d2 = <\/span><span style=\"color: #098658\">89.3<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> *s1 = <\/span><span style=\"color: #A31515\">&quot;Frodo&quot;<\/span><span style=\"color: #000000\">, *s2 = <\/span><span style=\"color: #A31515\">&quot;Bilbo&quot;<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; i1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; i2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(i1, i2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; d1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; d2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(d1, d2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; s1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; s2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(s1, s2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<p>This produces the following output:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"padding-top:0px;padding-bottom:0px\"><code><strong>5 &gt; 2 true\n45.2 &gt; 89.3 false\nFrodo &gt; Bilbo false\nProgram ended with exit code: 0<\/strong><\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-text-align-center\" style=\"font-size:clamp(15.747px, 0.984rem + ((1vw - 3.2px) * 0.645), 24px);\"><strong>But &#8220;Frodo&#8221; should be greater than &#8220;Bilbo&#8221; for normal sorting!<\/strong><br><strong>What&#8217;s wrong?<\/strong><\/p>\n<\/blockquote>\n\n\n\n<div style=\"height:34px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-text-align-left has-medium-font-size\">This result is because the <strong>isGreater<\/strong> function is relying on the type <strong>T<\/strong> to support the <strong>&gt;<\/strong> operator.&nbsp; In the case of the type <strong>const char<code> <\/code>*<\/strong>, the function is comparing <em>pointer values<\/em>, not the strings.<\/p>\n\n\n\n<p>This shows that function templates cannot always provide the right solution for all types.<\/p>\n\n\n\n<p>We need to specify that the behavior of max should be different for the type <strong>const char *<\/strong>.<\/p>\n\n\n\n<p>We do this by specifying a <em>template explicit specialization<\/em>.<\/p>\n\n\n\n<p>A <strong><em>Template Specialization<\/em><\/strong> consists of:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The keyword <strong>template<\/strong> followed by <strong>&lt;&gt;<\/strong> (with nothing between the brackets)<\/li>\n\n\n\n<li>Followed by the template name and a bracket pair containing the template parameters for the specialization<\/li>\n\n\n\n<li>The function parameter list<\/li>\n\n\n\n<li>followed by the function body.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  templcompare.h\n\/\/  Function Templates\n\/\/\n\/\/  Created by Bryan Higgs on 10\/11\/24.\n\/\/\n\n#ifndef templcompare_h\n#define templcompare_h\n\ntemplate &lt;typename T&gt;\nbool isGreater(const T &amp;value1, const T &amp;value2)\n{\n  if (value1 &gt; value2)\n    return true;\n  return false;\n}\n\ntemplate&lt;&gt;\nbool isGreater&lt;const char*&gt;\n              (const char * const &amp;value1,\n               const char * const &amp;value2)\n{\n  if ( strcmp(value1, value2) &gt; 0 )\n    return true;\n  return false;\n}\n\n#endif \/* templcompare_h *\/\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  templcompare.h<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Function Templates<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/11\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#ifndef<\/span><span style=\"color: #0000FF\"> templcompare_h<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#define<\/span><span style=\"color: #0000FF\"> templcompare_h<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">bool<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">&amp;<\/span><span style=\"color: #001080\">value1<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">&amp;<\/span><span style=\"color: #001080\">value2<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> (value1 &gt; value2)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">false<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\">&lt;&gt;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #0000FF\">bool<\/span><span style=\"color: #000000\"> isGreater&lt;<\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\">*&gt;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">              (<\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> * <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> &amp;value1,<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">               <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> * <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> &amp;value2)<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> ( <\/span><span style=\"color: #795E26\">strcmp<\/span><span style=\"color: #000000\">(value1, value2) &gt; <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\"> )<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">false<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#endif<\/span><span style=\"color: #008000\"> \/* templcompare_h *\/<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  templcompare_main.cpp\n\/\/  Function Templates\n\/\/\n\/\/  Created by Bryan Higgs on 10\/11\/24.\n\/\/\n\n#include &lt;iostream&gt;\n#include &quot;templcompare.h&quot;\n\nint main(int argc, const char * argv[])\n{\n  int i1 = 5, i2 = 2;\n  double d1 = 45.2, d2 = 89.3;\n  const char *s1 = &quot;Frodo&quot;, *s2 = &quot;Bilbo&quot;;\n  \n  std::cout &lt;&lt; i1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; i2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(i1, i2) &lt;&lt; std::endl;\n  std::cout &lt;&lt; d1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; d2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(d1, d2) &lt;&lt; std::endl;\n  std::cout &lt;&lt; s1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; s2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(s1, s2) &lt;&lt; std::endl;\n  \n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  templcompare_main.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Function Templates<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/11\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&quot;templcompare.h&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> i1 = <\/span><span style=\"color: #098658\">5<\/span><span style=\"color: #000000\">, i2 = <\/span><span style=\"color: #098658\">2<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\"> d1 = <\/span><span style=\"color: #098658\">45.2<\/span><span style=\"color: #000000\">, d2 = <\/span><span style=\"color: #098658\">89.3<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> *s1 = <\/span><span style=\"color: #A31515\">&quot;Frodo&quot;<\/span><span style=\"color: #000000\">, *s2 = <\/span><span style=\"color: #A31515\">&quot;Bilbo&quot;<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; i1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; i2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(i1, i2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; d1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; d2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(d1, d2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; s1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; s2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(s1, s2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Which produces the following output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>5 &gt; 2 true\n45.2 &gt; 89.3 false\nFrodo &gt; Bilbo true\nProgram ended with exit code: 0<\/strong><\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>So, now the strings (actually <strong>const char *<\/strong>) values are compared correctly.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_an_Ordinary_Function_to_Achieve_the_Same_Result\"><\/span>Using an Ordinary Function to Achieve the Same Result<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>It is possible to use an ordinary (non-template) function to achieve the same result:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  templcompare.h\n\/\/  Function Templates\n\/\/\n\/\/  Created by Bryan Higgs on 10\/11\/24.\n\/\/\n\n#ifndef templcompare_h\n#define templcompare_h\n\ntemplate &lt;typename T&gt;\nbool isGreater(const T &amp;value1, const T &amp;value2)\n{\n  if (value1 &gt; value2)\n    return true;\n  return false;\n}\n\nbool isGreater\n              (const char * const &amp;value1,\n               const char * const &amp;value2)\n{\n  if ( strcmp(value1, value2) &gt; 0 )\n    return true;\n  return false;\n}\n\n#endif \/* templcompare_h *\/\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  templcompare.h<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Function Templates<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/11\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#ifndef<\/span><span style=\"color: #0000FF\"> templcompare_h<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#define<\/span><span style=\"color: #0000FF\"> templcompare_h<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">bool<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">&amp;<\/span><span style=\"color: #001080\">value1<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">&amp;<\/span><span style=\"color: #001080\">value2<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> (value1 &gt; value2)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">false<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #0000FF\">bool<\/span><span style=\"color: #000000\"> isGreater<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">              (<\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> * <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> &amp;value1,<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">               <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> * <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> &amp;value2)<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> ( <\/span><span style=\"color: #795E26\">strcmp<\/span><span style=\"color: #000000\">(value1, value2) &gt; <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\"> )<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">false<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#endif<\/span><span style=\"color: #008000\"> \/* templcompare_h *\/<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  templcompare_main.cpp\n\/\/  Function Templates\n\/\/\n\/\/  Created by Bryan Higgs on 10\/11\/24.\n\/\/\n\n#include &lt;iostream&gt;\n#include &quot;templcompare.h&quot;\n\nint main(int argc, const char * argv[])\n{\n  int i1 = 5, i2 = 2;\n  double d1 = 45.2, d2 = 89.3;\n  const char *s1 = &quot;Frodo&quot;, *s2 = &quot;Bilbo&quot;;\n  \n  std::cout &lt;&lt; i1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; i2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(i1, i2) &lt;&lt; std::endl;\n  std::cout &lt;&lt; d1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; d2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(d1, d2) &lt;&lt; std::endl;\n  std::cout &lt;&lt; s1 &lt;&lt; &quot; &gt; &quot; &lt;&lt; s2 &lt;&lt; &quot; &quot; &lt;&lt; std::boolalpha\n            &lt;&lt; isGreater(s1, s2) &lt;&lt; std::endl;\n  \n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  templcompare_main.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Function Templates<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/11\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&quot;templcompare.h&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> i1 = <\/span><span style=\"color: #098658\">5<\/span><span style=\"color: #000000\">, i2 = <\/span><span style=\"color: #098658\">2<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\"> d1 = <\/span><span style=\"color: #098658\">45.2<\/span><span style=\"color: #000000\">, d2 = <\/span><span style=\"color: #098658\">89.3<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> *s1 = <\/span><span style=\"color: #A31515\">&quot;Frodo&quot;<\/span><span style=\"color: #000000\">, *s2 = <\/span><span style=\"color: #A31515\">&quot;Bilbo&quot;<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; i1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; i2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(i1, i2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; d1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; d2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(d1, d2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; s1 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &gt; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; s2 &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::boolalpha<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #795E26\">isGreater<\/span><span style=\"color: #000000\">(s1, s2) &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<p>However, this is <strong><em>not<\/em><\/strong> a template explicit specialization.<\/p>\n\n\n\n<p>When we define a non-template function, normal conversions are applied to the arguments.<\/p>\n\n\n\n<p>Then we specialize a template, conversions are not applied to the argument types.<\/p>\n\n\n\n<p>In a call to a specialized version of a template, the argument types in the call must match the specialized version function parameter types <em>exactly<\/em>. If they do not, then the compiler will instantiate an instantiation for the arguments from the template definition.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Template_Argument_Deduction\"><\/span>Template Argument Deduction<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When a function template is called, the types and values of the template arguments are determined by looking at the types of the function arguments.&nbsp; This is called <em>template argument deduction<\/em>.<\/p>\n\n\n\n<p>There are times when it is not possible for the compiler to deduce the proper template arguments for a function template:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  main.cpp\n\/\/  Template Argument Deduction\n\/\/\n\/\/  Created by Bryan Higgs on 10\/13\/24.\n\/\/\n\n#include &lt;iostream&gt;\n\ntemplate &lt;typename T&gt;\nT *create()\n{  \/\/ Make a T and return a pointer to it\n  return new T;\n}\n\nint main(int argc, const char * argv[])\n{\n  int *p = create();  \/\/ error: could not deduce\n                      \/\/ template argument for 'T'\n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  main.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Template Argument Deduction<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/13\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #795E26\">create<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><span style=\"color: #008000\">  \/\/ Make a T and return a pointer to it<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #AF00DB\">new<\/span><span style=\"color: #000000\"> T;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> *p = <\/span><span style=\"color: #795E26\">create<\/span><span style=\"color: #000000\">();<\/span><span style=\"color: #008000\">  \/\/ error: could not deduce<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">                      \/\/ template argument for &#39;T&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>&#8230; produces the following compile-time error:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"padding-top:0px;padding-bottom:0px\"><code><strong>main.cpp:18:12 No matching function for call to 'create'\n\nCandidate template ignored: couldn't infer template argument 'T'<\/strong><\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Explicit_Template_Specification\"><\/span>Explicit Template Specification<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The solution to this is to use <em>explicit template specification<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  main.cpp\n\/\/  Template Argument Deduction\n\/\/\n\/\/  Created by Bryan Higgs on 10\/13\/24.\n\/\/\n\n#include &lt;iostream&gt;\n\ntemplate &lt;typename T&gt;\nT *create()\n{  \/\/ Make a T and return a pointer to it\n  return new T;\n}\n\nint main(int argc, const char * argv[])\n{\n  int *p = create&lt;int&gt;();\n  \n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  main.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Template Argument Deduction<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/13\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #795E26\">create<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><span style=\"color: #008000\">  \/\/ Make a T and return a pointer to it<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #AF00DB\">new<\/span><span style=\"color: #000000\"> T;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> *p = <\/span><span style=\"color: #795E26\">create<\/span><span style=\"color: #000000\">&lt;<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\">&gt;();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>This now compiles.<\/p>\n<\/div>\n<\/div>\n\n\n\n<p>One common use of explicit specification is to provide a return type for a function template:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  ReturnType.cpp\n\/\/  Template Argument Deduction\n\/\/\n\/\/  Created by Bryan Higgs on 10\/13\/24.\n\/\/\n\n#include &lt;iostream&gt;\n\ntemplate &lt;typename T, typename U&gt;\nU implicit_cast(U u)\n{\n  std::cout &lt;&lt; &quot;T:&quot; &lt;&lt; typeid(T).name() &lt;&lt; &quot; &quot;\n            &lt;&lt; &quot;U:&quot; &lt;&lt; typeid(U).name() &lt;&lt; std::endl;\n  return u;\n}\n\nint main(int argc, const char * argv[])\n{\n  int ivalue = 5;\n  double dvalue = implicit_cast(ivalue);\n          \/\/ error: can't deduce T\n  dvalue = implicit_cast&lt;double&gt;(ivalue);\n          \/\/ T is double; U is int\n  char cvalue = implicit_cast&lt;char, double&gt;(ivalue);\n          \/\/ T is char; U is double\n  char *cptr = implicit_cast&lt;char *, int&gt;(ivalue);\n          \/\/ T is char *; U is int\n          \/\/ error can't convert int to char*\n  \n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  ReturnType.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Template Argument Deduction<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/13\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">U<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #267F99\">U<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #267F99\">U<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">u<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; <\/span><span style=\"color: #A31515\">&quot;T:&quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #0000FF\">typeid<\/span><span style=\"color: #000000\">(T).<\/span><span style=\"color: #795E26\">name<\/span><span style=\"color: #000000\">() &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #A31515\">&quot;U:&quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #0000FF\">typeid<\/span><span style=\"color: #000000\">(U).<\/span><span style=\"color: #795E26\">name<\/span><span style=\"color: #000000\">() &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> u;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> ivalue = <\/span><span style=\"color: #098658\">5<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\"> dvalue = <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">(ivalue);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ error: can&#39;t deduce T<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  dvalue = <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">&lt;<\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\">&gt;(ivalue);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ T is double; U is int<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> cvalue = <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">&lt;<\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\">&gt;(ivalue);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ T is char; U is double<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> *cptr = <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">&lt;<\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> *, <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\">&gt;(ivalue);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ T is char *; U is int<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ error can&#39;t convert int to char*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>which produces the following compile-time errors:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"padding-top:0px;padding-bottom:0px\"><code><strong>ReturnType.cpp:21:19 No matching function for call to 'implicit_cast'\n\nCandidate template ignored: couldn't infer template argument 'T'\n\nReturnType.cpp:27:9 Cannot initialize a variable of type 'char *' with an rvalue of type 'int'<\/strong>\n<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p>When we remove the offending statements:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"\/\/\n\/\/  ReturnType.cpp\n\/\/  Template Argument Deduction\n\/\/\n\/\/  Created by Bryan Higgs on 10\/13\/24.\n\/\/\n\n#include &lt;iostream&gt;\n\ntemplate &lt;typename T, typename U&gt;\nU implicit_cast(U u)\n{\n  std::cout &lt;&lt; &quot;T:&quot; &lt;&lt; typeid(T).name() &lt;&lt; &quot; &quot;\n            &lt;&lt; &quot;U:&quot; &lt;&lt; typeid(U).name() &lt;&lt; std::endl;\n  return u;\n}\n\nint main(int argc, const char * argv[])\n{\n  int ivalue = 5;\n  double dvalue = implicit_cast&lt;double&gt;(ivalue);\n          \/\/ T is double; U is int\n  char cvalue = implicit_cast&lt;char, double&gt;(ivalue);\n          \/\/ T is char; U is double\n  \n  return 0;\n}\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  ReturnType.cpp<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Template Argument Deduction<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/  Created by Bryan Higgs on 10\/13\/24.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">\/\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">#include<\/span><span style=\"color: #0000FF\"> <\/span><span style=\"color: #A31515\">&lt;iostream&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">template<\/span><span style=\"color: #000000\"> &lt;<\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">T<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">typename<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">U<\/span><span style=\"color: #000000\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #267F99\">U<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #267F99\">U<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">u<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::cout &lt;&lt; <\/span><span style=\"color: #A31515\">&quot;T:&quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #0000FF\">typeid<\/span><span style=\"color: #000000\">(T).<\/span><span style=\"color: #795E26\">name<\/span><span style=\"color: #000000\">() &lt;&lt; <\/span><span style=\"color: #A31515\">&quot; &quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            &lt;&lt; <\/span><span style=\"color: #A31515\">&quot;U:&quot;<\/span><span style=\"color: #000000\"> &lt;&lt; <\/span><span style=\"color: #0000FF\">typeid<\/span><span style=\"color: #000000\">(U).<\/span><span style=\"color: #795E26\">name<\/span><span style=\"color: #000000\">() &lt;&lt; <\/span><span style=\"color: #267F99\">std<\/span><span style=\"color: #000000\">::endl;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> u;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">main<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argc<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">const<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">*<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">argv<\/span><span style=\"color: #000000\">[])<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">int<\/span><span style=\"color: #000000\"> ivalue = <\/span><span style=\"color: #098658\">5<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\"> dvalue = <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">&lt;<\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\">&gt;(ivalue);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ T is double; U is int<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\"> cvalue = <\/span><span style=\"color: #795E26\">implicit_cast<\/span><span style=\"color: #000000\">&lt;<\/span><span style=\"color: #0000FF\">char<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #0000FF\">double<\/span><span style=\"color: #000000\">&gt;(ivalue);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">          \/\/ T is char; U is double<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>the program now compiles, runs, and produces the following output:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"padding-top:0px;padding-bottom:0px\"><code><strong>T:d U:i\nT:c U:d\nProgram ended with exit code: 0<\/strong><\/code><\/pre>\n\n\n\n<p>Translation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>T<\/code><\/strong> is of type <strong><code>double<\/code><\/strong>; <strong><code>U<\/code><\/strong> is of type <strong><code>int<\/code><\/strong><\/li>\n\n\n\n<li><strong><code>T<\/code><\/strong> is of type <strong><code>char<\/code><\/strong>; <strong><code>U<\/code><\/strong> is of type <code><strong>double<\/strong><\/code><\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-text-align-center has-large-font-size\"><strong>Name Mangling<\/strong><\/p>\n\n\n\n<p>Here I&#8217;m using <strong>typeid.name()<\/strong> to output the type of the variable. Unfortunately, the output of this function is implementation-dependent (see <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/types\/type_info\/name\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>). The output for this program, which used the gcc C++ compiler, is in &#8216;mangled&#8217; format.<\/p>\n\n\n\n<p>Here&#8217;s a breakdown of how types are represented in mangled names:<\/p>\n\n\n\n<p>Primitive Types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>void:<\/strong>&nbsp;<code>v<\/code><\/li>\n\n\n\n<li><strong>int:<\/strong>&nbsp;<code>i<\/code><\/li>\n\n\n\n<li><strong>char:<\/strong>&nbsp;<code>c<\/code><\/li>\n\n\n\n<li><strong>short:<\/strong>&nbsp;<code>s<\/code><\/li>\n\n\n\n<li><strong>long:<\/strong>&nbsp;<code>l<\/code><\/li>\n\n\n\n<li><strong>long long:<\/strong>&nbsp;<code>x<\/code><\/li>\n\n\n\n<li><strong>unsigned int:<\/strong>&nbsp;<code>Ui<\/code><\/li>\n\n\n\n<li><strong>unsigned char:<\/strong>&nbsp;<code>Uc<\/code><\/li>\n\n\n\n<li><strong>unsigned short:<\/strong>&nbsp;<code>Us<\/code><\/li>\n\n\n\n<li><strong>unsigned long:<\/strong>&nbsp;<code>Ul<\/code><\/li>\n\n\n\n<li><strong>unsigned long long:<\/strong>&nbsp;<code>Ux<\/code><\/li>\n\n\n\n<li><strong>float:<\/strong>&nbsp;<code>f<\/code><\/li>\n\n\n\n<li><strong>double:<\/strong>&nbsp;<code>d<\/code><\/li>\n\n\n\n<li><strong>bool:<\/strong>&nbsp;<code>b<\/code><\/li>\n\n\n\n<li><strong>wchar_t:<\/strong>&nbsp;<code>w<\/code><\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<div style=\"height:47px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-font-size has-medium-font-size\"><a class=\"wp-block-button__link has-palette-color-8-color has-text-color has-link-color wp-element-button\" href=\"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/topics\/c-details\/function-templates-2\/function-template-overloading\/\">Next: Function Template Overloading<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Template Explicit Specialization Let&#8217;s look at a simpler template function, one that returns whether the first value is greater than the second value: This produces the following output: But &#8220;Frodo&#8221; should be greater than &#8220;Bilbo&#8221; for normal sorting!What&#8217;s wrong? This result is because the isGreater function is relying on the type T to support the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2029,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2055","page","type-page","status-publish","hentry"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/pages\/2055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/comments?post=2055"}],"version-history":[{"count":3,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/pages\/2055\/revisions"}],"predecessor-version":[{"id":2093,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/pages\/2055\/revisions\/2093"}],"up":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/pages\/2029"}],"wp:attachment":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalCPlusPlusProgramming\/index.php\/wp-json\/wp\/v2\/media?parent=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}