{"id":3419,"date":"2013-12-14T16:00:00","date_gmt":"2013-12-14T16:00:00","guid":{"rendered":"http:\/\/localhost:8105\/?p=3419"},"modified":"2021-12-04T21:43:36","modified_gmt":"2021-12-04T21:43:36","slug":"found-out-c11-has-the-following-two-gems","status":"publish","type":"post","link":"https:\/\/blog.shahada.abubakar.net\/?p=3419","title":{"rendered":"Found out C++11 has the following two gems:"},"content":{"rendered":"<div id=\"content\">Found out C++11 has the following two gems:\n<p>\u00a0<\/p>\n<p><i>std::stoi, std::stol, std::stoll ,\u00a0std::stof, std::stod, std::stold,\u00a0std::stof, std::stod, std::stold<\/i> \u00a0&#8211; Coverts a C++ string to numeric type. Similar to the good old atoi, atod, atof but take C++ strings so you don&#8217;t need to add .c_str() to each one. Saves a few keystrokes and looks neater.<\/p>\n<p><i>std::to_string<\/i> &#8211; converts a numeric type to a string. This is useful as it saves a few lines from converting via sprinf or streambuf.<\/p>\n<p>They work on gcc 4.8.1 with Ubuntu 13.10.\u00a0<\/p>\n<p>CAVEAT: So I started using them in some new code, only to discover that they don&#8217;t work on my buildroot cross-compiler environment which is on gcc 4.8.0 (although 4.8.0 supports other C++11 features). Seems MINGW users are having the same issues also. Spent the last hour reverting my code. 8-(<\/p>\n<p><a class=\"ot-hashtag bidi_isolate\" href=\"https:\/\/plus.google.com\/s\/%23C%2B%2B11\/posts\" rel=\"nofollow\">#C++11<\/a><\/p>\n<hr \/>LINK:<br \/><a href=\"http:\/\/cpp11surprises.blogspot.com\/2013\/01\/stdtostring.html\"><br \/>std::to_string()<\/a><\/div>\n<div>\u00a0<\/div>\n<div><br \/><br \/><i>This post was originally <a href=\"https:\/\/plus.google.com\/+shahadaabubakar\/posts\/JvtHanx7n8P\">published<\/a> publicly on <a href=\"http:\/\/plus.google.com\">Google+<\/a> at 2013-12-15 19:03:38+0800<\/i><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/1\/18\/ISO_C%2B%2B_Logo.svg\/640px-ISO_C%2B%2B_Logo.svg.png\" alt=\"\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Found out C++11 has the following two gems: \u00a0 std::stoi, std::stol, std::stoll ,\u00a0std::stof, std::stod, std::stold,\u00a0std::stof, std::stod, std::stold \u00a0&#8211; Coverts a C++ string to numeric type. Similar to the good old atoi, atod, atof but&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127],"tags":[],"class_list":["post-3419","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/3419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3419"}],"version-history":[{"count":2,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/3419\/revisions"}],"predecessor-version":[{"id":6571,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=\/wp\/v2\/posts\/3419\/revisions\/6571"}],"wp:attachment":[{"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.shahada.abubakar.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}