{"id":6126,"date":"2021-04-29T19:56:19","date_gmt":"2021-04-29T19:56:19","guid":{"rendered":"https:\/\/www.modernescpp.com\/index.php\/template-get-insight\/"},"modified":"2021-04-29T19:56:19","modified_gmt":"2021-04-29T19:56:19","slug":"template-get-insight","status":"publish","type":"post","link":"https:\/\/www.modernescpp.com\/index.php\/template-get-insight\/","title":{"rendered":"Templates &#8211; First Steps"},"content":{"rendered":"<p>The idea of this post is quite simple. I want to visualize templates and, in particular, the template instantiation process. Thanks to<a href=\"https:\/\/cppinsights.io\/\"> C++ Insights<\/a>, this visualization is pretty straightforward.<\/p>\n<p><!--more--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6121\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/templatesNew.png\" alt=\"templates\" width=\"650\" height=\"396\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/templatesNew.png 902w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/templatesNew-300x183.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/templatesNew-768x468.png 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>Templates (class templates or function templates) are families of classes or functions. When you instantiate a template, you create a concrete class or a concrete function out of these families of classes or functions. Here are the first straightforward questions I want to answer. For simplicity reasons, I sometimes call a class template a generic class and a function template a generic function.<\/p>\n<h2>When should I use a template?<\/h2>\n<p>You should use a template when your function or class stands for such a generic idea that this idea is not bound to a concrete type. For example, a function such as <code>max <\/code>or a container such as <code>vector<\/code> are usable for many types.<\/p>\n<h2>How can I create a template?<\/h2>\n<p>I assume you have implemented a function <code>max<\/code> accepting two ints.<\/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: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">max<\/span>(<span style=\"color: #007788; font-weight: bold;\">int<\/span> lhs, <span style=\"color: #007788; font-weight: bold;\">int<\/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<\/pre>\n<\/div>\n<p>&nbsp;Making a template out of the function is, in general straightforward.<\/p>\n<ol>\n<li>Put the line <code>template &lt;typename T&gt;<\/code> before the function<\/li>\n<li>Replace the concrete type <code>int<\/code> with the type parameter <code>T<\/code>.<\/li>\n<\/ol>\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: #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;\">\/\/ (1)<\/span>\r\nT max(T lhs, T rhs) {              <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/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<\/pre>\n<\/div>\n<p>I have to mark two additional remarks. First, instead of the name <code>typename<\/code>, you can also use <code>class<\/code>. I strongly suggest <code>typename<\/code>, because<code> T <\/code>must not be a class but<code> <\/code>can be a&nbsp; type, a non-type, or a template. Second, by convention, we use<code> T<\/code> as the name for the first type parameter.<\/p>\n<p>The same procedure also works when transforming a class into a template.<\/p>\n<p>Now I have come to precisely the point where<a href=\"https:\/\/cppinsights.io\/\"> C++ Insights<\/a>, provides me with valuable services.<\/p>\n<\/p>\n<h2>What happens when I instantiate a template?<\/h2>\n<p>Let instantiate the function template max for <code>int<\/code> and <code>double<\/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: #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(T lhs, T 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    max(<span style=\"color: #ff6600;\">10<\/span>, <span style=\"color: #ff6600;\">5<\/span>);\r\n    max(<span style=\"color: #ff6600;\">10.5<\/span>, <span style=\"color: #ff6600;\">5.5<\/span>);\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p><a href=\"https:\/\/cppinsights.io\/lnk?code=dGVtcGxhdGUgPHR5cGVuYW1lIFQ+ClQgbWF4KFQgbGhzLCBUIHJocykgewogICAgcmV0dXJuIChsaHMgPiByaHMpPyBsaHMgOiByaHM7Cn0KCmludCBtYWluKCkgewogIAogICAgbWF4KDEwLCA1KTsKICAgIG1heCgxMC41LCA1LjUpOwogIAp9&amp;insightsOptions=cpp2a&amp;std=cpp2a&amp;rev=1.0\"> C++ Insights<\/a> provides a deeper insight into this automatic process of template instantiation:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6122\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/functionTemplateInstantiation.png\" alt=\"functionTemplateInstantiation\" width=\"500\" height=\"650\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/functionTemplateInstantiation.png 568w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/functionTemplateInstantiation-231x300.png 231w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>The process of template instantiation creates lines 6 &#8211; 23. Let me write a few words about the instantiation of the function <code>max<\/code> for the two ints (lines 6 &#8211; 13). Line 6 in the screenshot expresses that line 8 in the source file (<code>max(10, 5)<\/code>) causes the generation of lines 6 &#8211; 13. I assume the first two lines of the compiler-generate code are the most interesting ones.<\/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: #006699; font-weight: bold;\">template<\/span><span style=\"color: #555555;\">&lt;&gt;<\/span>\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> max<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span><span style=\"color: #555555;\">&gt;<\/span>(<span style=\"color: #007788; font-weight: bold;\">int<\/span> lhs, <span style=\"color: #007788; font-weight: bold;\">int<\/span> rhs)\r\n{\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<\/pre>\n<\/div>\n<p><code>max<\/code> is a fully specialized function template for int:<code> max<strong>&lt;int&gt;<\/strong><\/code>.&nbsp; The generic part is empty:<code> template&lt;&gt;<\/code>. The compiler generates out of the family of <code>max<\/code>-functions one concrete function for <code>int<\/code>. Does this also mean that the compiler generates a concrete function for each used type?<\/p>\n<h2>What happens, when I instantiate a template more than once for the same type?<\/h2>\n<p>My next example is based on class templates. Here is a simple container two times instantiated for <code>int<\/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: #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: #007788; font-weight: bold;\">int<\/span> N<span style=\"color: #555555;\">&gt;<\/span>\r\n<span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">Array<\/span>{\r\n <span style=\"color: #9999ff;\">public:<\/span>\r\n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> getSize() <span style=\"color: #006699; font-weight: bold;\">const<\/span>{\r\n        <span style=\"color: #006699; font-weight: bold;\">return<\/span> N;\r\n    }\r\n <span style=\"color: #9999ff;\">private:<\/span>\r\n    T elem[N];\r\n};\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\r\n  \r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span>, <span style=\"color: #ff6600;\">5<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr1;  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)<\/span>\r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span>, <span style=\"color: #ff6600;\">10<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr2; <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span>, <span style=\"color: #ff6600;\">5<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr3;  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (3)<\/span>\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>I instantiated two times<code> Array&lt;int, 5&gt;<\/code> (lines (1) and (3)) and one time<code> Array&lt;int, 10&gt;<\/code> (line 2). When you study the output of <a href=\"https:\/\/cppinsights.io\/lnk?code=dGVtcGxhdGUgPHR5cGVuYW1lIFQsIGludCBOPgpjbGFzcyBBcnJheXsKIHB1YmxpYzoKICAgIGludCBnZXRTaXplKCkgY29uc3R7CiAgICAgICAgcmV0dXJuIE47CiAgICB9CiBwcml2YXRlOgogICAgVCBlbGVtW05dOwp9OwoKaW50IG1haW4oKSB7CiAgCiAgICBBcnJheTxpbnQsIDU+IG15QXJyMTsKICAgIEFycmF5PGludCwgMTA+IG15QXJyMjsKICAgIEFycmF5PGludCwgNT4gbXlBcnIzOwogIAp9&amp;insightsOptions=cpp2a&amp;std=cpp2a&amp;rev=1.0\">C++ Insights<\/a>, you recognize that the second instantiation of <code>Array&lt;int, 5&gt;<\/code> (line 3) uses the first instantiation already triggered by line (1). Here are the relevant parts of the output.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6123\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateInstantiation.png\" alt=\"classTemplateInstantiation\" width=\"400\" height=\"611\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateInstantiation.png 475w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateInstantiation-196x300.png 196w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Are we done with this example? No! There are two additional exciting observations I want to make.<\/p>\n<p>First, the process of template instantiation is lazy. Second, I use a non-type template parameter.<\/p>\n<h3>Template instantiation is lazy<\/h3>\n<p>Did you recognize that the member function <code>getSize<\/code>() was not instantiated? Only the declaration of the member function is available. The process of template instantiation is lazy. Meaning if you don&#8217;t need it will not be instantiated.&nbsp;This works fine so far that you can use invalid code in a member function. Of course, the member function must not be called. If you don&#8217;t believe me, compile the following small program. First, disable line (1), and second, enable line (1).<\/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;\">\/\/ number.cpp<\/span>\r\n\r\n<span style=\"color: #009999;\">#include &lt;cmath&gt;<\/span>\r\n<span style=\"color: #009999;\">#include &lt;string&gt;<\/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\n<span style=\"color: #006699; font-weight: bold;\">struct<\/span> Number {\r\n\t<span style=\"color: #007788; font-weight: bold;\">int<\/span> absValue() {\r\n        <span style=\"color: #006699; font-weight: bold;\">return<\/span> std<span style=\"color: #555555;\">::<\/span>abs(val);\r\n    }\r\n  T val{};\r\n};\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\r\n  \r\n    Number<span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>string<span style=\"color: #555555;\">&gt;<\/span> numb;\r\n    <span style=\"color: #0099ff; font-style: italic;\">\/\/ numb.absValue();       \/\/ (1)<\/span>\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>Let&#8217;s go back to my previous program and invoke <code>getSize()<\/code>. Here is the modified <code>main<\/code> program.<\/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: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\r\n  \r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span>, <span style=\"color: #ff6600;\">5<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr1;  \r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span>, <span style=\"color: #ff6600;\">10<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr2; \r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span>, <span style=\"color: #ff6600;\">5<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr3;  \r\n    myArr3.getSize();     <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)<\/span>\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>&nbsp;Accordingly, the following screenshot shows the compiler-generated code for the member function <code>getSize()<\/code> (lines 18 &#8211; 21).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6124\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateGetSize.png\" alt=\"classTemplateGetSize\" width=\"400\" height=\"628\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateGetSize.png 450w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateGetSize-191x300.png 191w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4><code>int<\/code> as a non-type template parameter<\/h4>\n<p>I used in this example two type-parameters in the second one is, in particular, an <code>int. int <\/code>is an example of a non-type template parameter. Besides <code>int<\/code>, you can use all integral types, floating-point types (C++20), pointers, or references as non-type template parameters. What happens when I instantiate two arrays of different lengths?<\/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: #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: #007788; font-weight: bold;\">int<\/span> N<span style=\"color: #555555;\">&gt;<\/span>\r\n<span style=\"color: #006699; font-weight: bold;\">class<\/span> <span style=\"color: #00aa88; font-weight: bold;\">Array<\/span>{\r\n <span style=\"color: #9999ff;\">public:<\/span>\r\n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> getSize() <span style=\"color: #006699; font-weight: bold;\">const<\/span>{\r\n        <span style=\"color: #006699; font-weight: bold;\">return<\/span> N;\r\n    }\r\n <span style=\"color: #9999ff;\">private:<\/span>\r\n    T elem[N];\r\n};\r\n\r\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\r\n  \r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">float<\/span>, <span style=\"color: #ff6600;\">5<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr1;\r\n    Array<span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">float<\/span>, <span style=\"color: #ff6600;\">10<\/span><span style=\"color: #555555;\">&gt;<\/span> myArr2;\r\n  \r\n}\r\n<\/pre>\n<\/div>\n<p>&nbsp;You probably guessed it. Two arrays are instantiated. Here is the crucial output from <a href=\"https:\/\/cppinsights.io\/lnk?code=dGVtcGxhdGUgPHR5cGVuYW1lIFQsIGludCBOPgpjbGFzcyBBcnJheXsKIHB1YmxpYzoKICAgIGludCBnZXRTaXplKCkgY29uc3R7CiAgICAgICAgcmV0dXJuIE47CiAgICB9CiBwcml2YXRlOgogICAgVCBlbGVtW05dOwp9OwoKaW50IG1haW4oKSB7CiAgCiAgICBBcnJheTxmbG9hdCwgNT4gbXlBcnIxOwogICAgQXJyYXk8ZmxvYXQsIDEwPiBteUFycjI7CiAgCn0=&amp;insightsOptions=cpp2a&amp;std=cpp2a&amp;rev=1.0\">C++ Insights<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6125\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateTwoInts.PNG\" alt=\"classTemplateTwoInts\" width=\"450\" height=\"591\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateTwoInts.PNG 497w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/04\/classTemplateTwoInts-229x300.png 229w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/p>\n<p>This means that both instantiations use different <code>int<\/code> values create different types.<\/p>\n<h2>What&#8217;s next<\/h2>\n<p>After these first steps with templates, I make, in my <a href=\"https:\/\/www.modernescpp.com\/index.php\/function-templates\">next post, <\/a>a deep dive into function templates.<\/p>\n<p>&nbsp;<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The idea of this post is quite simple. I want to visualize templates and, in particular, the template instantiation process. Thanks to C++ Insights, this visualization is pretty straightforward.<\/p>\n","protected":false},"author":21,"featured_media":6121,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[376],"tags":[],"class_list":["post-6126","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\/6126","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=6126"}],"version-history":[{"count":0,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6126\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media\/6121"}],"wp:attachment":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=6126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=6126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=6126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}