{"id":5775,"date":"2019-09-08T12:01:07","date_gmt":"2019-09-08T12:01:07","guid":{"rendered":"https:\/\/www.modernescpp.com\/index.php\/c-core-guidelines-the-profiles-type-safety-bounds-safety-and-lifetime-safety\/"},"modified":"2023-08-11T16:06:07","modified_gmt":"2023-08-11T16:06:07","slug":"c-core-guidelines-the-profiles-type-safety-bounds-safety-and-lifetime-safety","status":"publish","type":"post","link":"https:\/\/www.modernescpp.com\/index.php\/c-core-guidelines-the-profiles-type-safety-bounds-safety-and-lifetime-safety\/","title":{"rendered":"C++ Core Guidelines: Type Safety"},"content":{"rendered":"\n<p>The C++ core guidelines support three profiles: type safety, bounds safety, and lifetime safety. Thanks to the guideline support library (GSL), you can check your code against these profiles. Today, I start with the profile type safety.<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1188\" height=\"1280\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/checklist-1295319_1280.png\" alt=\"checklist 1295319 1280\" class=\"wp-image-5772\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/checklist-1295319_1280.png 1188w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/checklist-1295319_1280-278x300.png 278w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/checklist-1295319_1280-950x1024.png 950w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/checklist-1295319_1280-768x827.png 768w\" sizes=\"auto, (max-width: 1188px) 100vw, 1188px\" \/><\/figure>\n\n\n\n<p>If you don&#8217;t know what a profile is, read my last post: <a href=\"https:\/\/www.modernescpp.com\/index.php\/profiles-in-the-c-core-guidelines\">C++ Core Guidelines: Profiles<\/a>. Although the idea of a profile is it to target a specific goal, it needs assistance from the other profiles. This said, the type safety profile needs, for example, assistance from the bounds safety, and lifetime safety profile. Now, let&#8217;s dive into the type safety.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/isocpp.github.io\/CppCoreGuidelines\/CppCoreGuidelines#SS-type\">Type Safety<\/a><\/h2>\n\n\n\n<p>Type safety means that you use the types correctly and, therefore, avoid unsafe casts and unions. Type safety consists of eight rules which are called type. The rules start with don&#8217;t, always, or avoid and refer to existing rules. If necessary, I will add content to the rules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Type 1:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>Don\u2019t use <code class=\"highlighter-rouge no-highlight\">reinterpret_cast<\/code><\/p>\n<\/li>\n\n\n\n<li>\n<p><code class=\"highlighter-rouge no-highlight\"><\/code><code class=\"highlighter-rouge no-highlight\"><\/code>Don\u2019t use <code class=\"highlighter-rouge no-highlight\">static_cast<\/code> for arithmetic types<\/p>\n<\/li>\n\n\n\n<li>\n<p>Don\u2019t cast between pointer types where the source type and the target type are the same<\/p>\n<\/li>\n\n\n\n<li>Don\u2019t cast between pointer types when the conversion could be implicit<\/li>\n<\/ul>\n\n\n\n<p>The answer to this doesn&#8217;t boil down to two points:<\/p>\n\n\n\n<p>Avoid&nbsp; in particular C-casts and prefer if necessarily named casts:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Avoid casts:<\/h4>\n\n\n\n<p>Let&#8217;s see what will happen if I screw up the type system.<\/p>\n\n\n\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;\">\/\/ casts.cpp<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #009999;\">#include &lt;iostream&gt;<\/span><\/p>\n<p><span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>(){<\/p>\n<p><span style=\"color: #007788; font-weight: bold;\">&nbsp; &nbsp; double<\/span> d <span style=\"color: #555555;\">=<\/span> <span style=\"color: #ff6600;\">2<\/span>;<br><span style=\"color: #006699; font-weight: bold;\">&nbsp; &nbsp; auto<\/span> p <span style=\"color: #555555;\">=<\/span> (<span style=\"color: #007788; font-weight: bold;\">long<\/span><span style=\"color: #555555;\">*<\/span>)<span style=\"color: #555555;\">&amp;<\/span>d;<br><span style=\"color: #006699; font-weight: bold;\">&nbsp; &nbsp; auto<\/span> q <span style=\"color: #555555;\">=<\/span> (<span style=\"color: #007788; font-weight: bold;\">long<\/span> <span style=\"color: #007788; font-weight: bold;\">long<\/span><span style=\"color: #555555;\">*<\/span>)<span style=\"color: #555555;\">&amp;<\/span>d;<br>&nbsp; &nbsp; std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> d <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">&#8216; &#8216;<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #555555;\">*<\/span>p <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">&#8216; &#8216;<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #555555;\">*<\/span>q <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">&#8216;\\n&#8217;<\/span>;<\/p>\n<p>}<\/p>\n<\/div>\n\n\n\n<p>Neither the result with the Visual Studio compiler<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"91\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2018\/02\/castsWin.png\" alt=\"castsWin\" class=\"wp-image-5384\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2018\/02\/castsWin.png 320w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2018\/02\/castsWin-300x85.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/figure>\n\n\n\n<p>nor the result with the GCC or the Clang compiler is promising.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"364\" height=\"51\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2018\/02\/castsGccClang.png\" alt=\"castsGccClang\" class=\"wp-image-5385\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2018\/02\/castsGccClang.png 364w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2018\/02\/castsGccClang-300x42.png 300w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/figure>\n\n\n\n<p>What is so bad about the C-cast? You don&#8217;t see which cast is performed. If you use a C-cast, a combination of casts will be applied if necessary. Roughly speaking, a C-cast starts with a <span style=\"font-family: 'courier new', courier;\">static_cast<\/span>, continues with a <span style=\"font-family: 'courier new', courier;\">const_cast<\/span>, and finally performs a <span style=\"font-family: 'courier new', courier;\">reinterpret_cast.<\/span><\/p>\n\n\n\n<p>There is another issue I don&#8217;t like about a C-cast. It&#8217;s challenging to find C-casts in your source code. This remark does not hold for C++ casts such as <span style=\"font-family: courier new, courier;\">dynamic_cast, const_cast, static_cast, <\/span>or<span style=\"font-family: courier new, courier;\"> reinterpret_cast.<\/span><\/p>\n\n\n\n<p>Of course, you know how I will continue: <em>explicit is better than implicit.<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Prefer named C++-casts<\/h4>\n\n\n\n<p>Including the GSL, C++ offers eight different named casts.<\/p>\n\n\n\n<p>Here are they including a short description:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">static_cast: <\/span>conversion between similar types such as pointer types or numeric types<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">const_cast: <\/span>adds or removes const or volatile<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">reinterpret_cast: <\/span>converts between pointers or between integral types and pointers<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">dynamic_ cast: <\/span>converts between polymorph pointers or references in the same class hierarchy<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">std::move: <\/span>converts to an rvalue reference<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">std::forward: <\/span>converts to an rvalue reference<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">gsl::narrow_cast: applies<\/span>&nbsp;a <span style=\"font-family: 'courier new', courier;\">static_cast<\/span><\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: 'courier new', courier;\">gsl::narrow: applies&nbsp;<\/span>a <span style=\"font-family: 'courier new', courier;\">static_cast<\/span><\/li>\n<\/ul>\n\n\n\n<p>I know the description is concise. I want to make a least two remarks:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>GSL stands for guideline support library and is a header-only library using the namespace <span style=\"font-family: courier new, courier;\">gsl<\/span>.&nbsp; The GSL can automatically check the rules of the C++ core guidelines and, in particular, the profiles. I will write about this check in a future post. I have already written a post to the GSL: <a href=\"https:\/\/www.modernescpp.com\/index.php\/c-core-guideline-the-guidelines-support-library\">C++ Core Guidelines: The Guidelines Support Library<\/a>.<\/li>\n\n\n\n<li>What? <span style=\"font-family: 'courier new', courier;\">std::move<\/span>&nbsp;and <span style=\"font-family: 'courier new', courier;\">std::forward<\/span> are casts? Let&#8217;s have a closer look at the internals of <span style=\"font-family: 'courier new', courier;\">std::move: static_cast<span style=\"color: #555555;\">&lt;<\/span>std<span style=\"color: #555555;\">::<\/span>remove_reference<span style=\"color: #555555;\">&lt;decltype(arg)<\/span><span style=\"color: #555555;\">&gt;::<\/span>type<span style=\"color: #555555;\">&amp;&amp;&gt;<\/span>(arg). <\/span>First, the type of argument <span style=\"font-family: 'courier new', courier;\">arg<\/span> is determined by <span style=\"font-family: 'courier new', courier;\">decltype(arg)<\/span>. Then all references are removed, and two new references are added. The function<span style=\"font-family: 'courier new', courier;\"> std::remove_reference<\/span> is from the type-traits library. I have already written a few posts to the <a href=\"https:\/\/www.modernescpp.com\/index.php\/tag\/type-traits\">type-traits library.<\/a>&nbsp; In the end, each argument <span style=\"font-family: courier new, courier;\">arg<\/span> to <span style=\"font-family: courier new, courier;\">std:<\/span>:move comes out as an rvalue reference.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Type 2:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Don\u2019t use <code class=\"highlighter-rouge no-highlight\">static_cast<\/code> to downcast<\/li>\n<\/ul>\n\n\n\n<p>I can give you a short answer: Use <span style=\"font-family: courier new, courier;\">dynamic_cast<\/span> instead. I have already written about this topic in my post <a href=\"https:\/\/www.modernescpp.com\/index.php\/c-core-guidelines-accessing-objects-in-a-hierarchy\">C++ Core Guidelines: Accessing Objects in a Hierarchy<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Type 3:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Don\u2019t use <code class=\"highlighter-rouge no-highlight\">const_cast<\/code> to cast away <code class=\"highlighter-rouge no-highlight\">const<\/code><\/li>\n<\/ul>\n\n\n\n<p>Let me be more specific. Casting away <span style=\"font-family: courier new, courier;\">const<\/span> is undefined behavior if the underlying object, such as <span style=\"font-family: 'courier new', courier;\">constInt<\/span> is not mutable.<\/p>\n\n\n\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;\">const<\/span> <span style=\"color: #007788; font-weight: bold;\">int<\/span> constInt <span style=\"color: #555555;\">=<\/span> <span style=\"color: #ff6600;\">10<\/span>;\n<span style=\"color: #006699; font-weight: bold;\">const<\/span> <span style=\"color: #007788; font-weight: bold;\">int<\/span><span style=\"color: #555555;\">*<\/span> pToConstInt <span style=\"color: #555555;\">=<\/span> <span style=\"color: #555555;\">&amp;<\/span>constInt;\n \n<span style=\"color: #007788; font-weight: bold;\">int<\/span><span style=\"color: #555555;\">*<\/span> pToInt <span style=\"color: #555555;\">=<\/span> <span style=\"color: #006699; font-weight: bold;\">const_cast<\/span><span style=\"color: #555555;\">&lt;<\/span><span style=\"color: #007788; font-weight: bold;\">int<\/span><span style=\"color: #555555;\">*&gt;<\/span>(pToConstInt);\n<span style=\"color: #555555;\">*<\/span>pToInt <span style=\"color: #555555;\">=<\/span> <span style=\"color: #ff6600;\">12<\/span>;          <span style=\"color: #0099ff; font-style: italic;\">\/\/ undefined behaviour<\/span>\n<\/pre>\n<\/div>\n\n\n\n<p>If you don&#8217;t believe me, there is a footnote in the C standard [ISO\/IEC 9899:2011] (subclause 6.7.3, paragraph 4) relevant to the C++ standard:&nbsp;<em>The implementation may place a const object that is not volatile in a read-only region of storage. Moreover, the implementation need not allocate storage for such an object if its address is never used.&nbsp; <\/em>This means that a modification of an original constant object may have no result.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Type 4:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Don\u2019t use C-style <code class=\"highlighter-rouge no-highlight\">(T)expression<\/code> or functional <code class=\"highlighter-rouge no-highlight\">T(expression)<\/code> casts<\/li>\n<\/ul>\n\n\n\n<p>The first part of this don&#8217;t is relatively easy to answer: prefer named casts such as in type 1.<\/p>\n\n\n\n<p>The functional <span style=\"font-family: courier new, courier;\">T(e)<\/span> cast is used to construct <span style=\"font-family: courier new, courier;\">T<\/span> from the expression e. Let me show what can happen if you use the functional cast incorrectly.<\/p>\n\n\n\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;\">\/\/ functionalCast.cpp<\/span>\n\n<span style=\"color: #007788; font-weight: bold;\">void<\/span> <span style=\"color: #cc00ff;\">f<\/span>(<span style=\"color: #007788; font-weight: bold;\">int<\/span> x, <span style=\"color: #007788; font-weight: bold;\">long<\/span> y, <span style=\"color: #007788; font-weight: bold;\">double<\/span> d, <span style=\"color: #007788; font-weight: bold;\">long<\/span> <span style=\"color: #007788; font-weight: bold;\">long<\/span> l){\n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c1(x);   \n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c2(y);   \n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c3(d);   \n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c4(l);\n}\n\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>(){  \n  f(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">3l<\/span>, <span style=\"color: #ff6600;\">3.0<\/span>, <span style=\"color: #ff6600;\">3ll<\/span>);\n}\n<\/pre>\n<\/div>\n\n\n\n<p>The function <span style=\"font-family: courier new, courier;\">f<\/span> takes four arguments and uses these arguments for initializing <span style=\"font-family: courier new, courier;\">char<\/span>&#8216;s. You get what you deserve and can only hope for a warning. <a href=\"https:\/\/cppinsights.io\/s\/6f300871\">C++ Insights<\/a> shows explicitly how your code is transformed. A <span style=\"font-family: courier new, courier;\">static_cast<\/span> is applied to each argument.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"981\" height=\"756\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/cppInsightFunctionalCast.png\" alt=\"cppInsightFunctionalCast\" class=\"wp-image-5773\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/cppInsightFunctionalCast.png 981w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/cppInsightFunctionalCast-300x231.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/cppInsightFunctionalCast-768x592.png 768w\" sizes=\"auto, (max-width: 981px) 100vw, 981px\" \/><\/figure>\n\n\n\n<p>This process is called narrowing conversion and should be detected by the compiler. Using curly braces instead of round braces checks if a narrowing conversion happens. The C++ compiler must write a warning but typically throws an error when this happens. If you want to be sure that narrowing conversion always triggers an error, treat narrowing warnings with GCC and Clang as an error with <span style=\"font-family: courier new, courier;\">-Werror=narrowing<\/span>. Here is the modified program using curly braces for initialization.<\/p>\n\n\n\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;\">\/\/ functionalCastCurlyBraces.cpp<\/span>\n\n<span style=\"color: #007788; font-weight: bold;\">void<\/span> <span style=\"color: #cc00ff;\">f<\/span>(<span style=\"color: #007788; font-weight: bold;\">int<\/span> x, <span style=\"color: #007788; font-weight: bold;\">long<\/span> y, <span style=\"color: #007788; font-weight: bold;\">double<\/span> d, <span style=\"color: #007788; font-weight: bold;\">long<\/span> <span style=\"color: #007788; font-weight: bold;\">long<\/span> l){\n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c1{x};   \n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c2{y};   \n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c3{d};   \n    <span style=\"color: #007788; font-weight: bold;\">char<\/span> c4{l};\n}\n\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>(){  \n  f(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">3l<\/span>, <span style=\"color: #ff6600;\">3.0<\/span>, <span style=\"color: #ff6600;\">3ll<\/span>);\n}\n<\/pre>\n<\/div>\n\n\n\n<p>Now, the compiler detects what is going wrong.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1564\" height=\"681\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/narrowingConversionError.png\" alt=\"narrowingConversionError\" class=\"wp-image-5774\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/narrowingConversionError.png 1564w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/narrowingConversionError-300x131.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/narrowingConversionError-1024x446.png 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/narrowingConversionError-768x334.png 768w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2019\/09\/narrowingConversionError-1536x669.png 1536w\" sizes=\"auto, (max-width: 1564px) 100vw, 1564px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s next?<\/h2>\n\n\n\n<p>In the<a href=\"https:\/\/www.modernescpp.com\/index.php\/c-core-guidelines-the-profiles-type-safety-bounds-safety-and-lifetime-safety\"> next post<\/a>, I will finish the rules to type safety. They are about initialization, unions, and varargs. Now, I have to prepare for a fascinating week in Aurora. I give a two-day concurrency workshop, a back-to-basics talk on concurrency, and a presentation on concepts at the <a href=\"https:\/\/cppcon.org\/\">CppCon<\/a>.<\/p>\n\n\n\n<p><strong>&nbsp;&nbsp;<a href=\"https:\/\/www.takeupcode.com\/\">&nbsp; <\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The C++ core guidelines support three profiles: type safety, bounds safety, and lifetime safety. Thanks to the guideline support library (GSL), you can check your code against these profiles. Today, I start with the profile type safety.<\/p>\n","protected":false},"author":21,"featured_media":5772,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[372],"tags":[466],"class_list":["post-5775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-modern-c","tag-safety"],"_links":{"self":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/5775","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=5775"}],"version-history":[{"count":2,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/5775\/revisions"}],"predecessor-version":[{"id":8049,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/5775\/revisions\/8049"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media\/5772"}],"wp:attachment":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=5775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=5775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=5775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}