{"id":4384,"date":"2026-11-01T14:31:50","date_gmt":"2026-11-01T09:01:50","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=4384"},"modified":"2026-11-01T14:32:35","modified_gmt":"2026-11-01T09:02:35","slug":"exploring-c-bit-manipulation-functions","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/","title":{"rendered":"Exploring C++ Bit Manipulation Functions"},"content":{"rendered":"<p>Developers who work on low-level programming in <em><strong>C++<\/strong><\/em>, for example controlling <em><strong>IoT<\/strong><\/em> devices, know the importance of bit manipulation. Prior to <em><strong>C++20<\/strong><\/em>, we wrote our own set of functions according to our specific requirements. <em><strong>C++20<\/strong><\/em> introduced <em><strong>&lt;bit&gt;<\/strong><\/em> header and this was later improved in <em><strong>C++23<\/strong><\/em>. The current set of functions provide substantial functionality. In today\u2019s article, let us go over some of them.<\/p>\n<p>Let us start with a simple requirement. We are given a positive integer and we want to calculate the number of bits required to represent this number. The <em><strong>bit_width<\/strong><\/em> function does this. Given an integer argument, it returns the required bit size. Take a look at the following example:<\/p>\n<figure id=\"attachment_4385\" aria-describedby=\"caption-attachment-4385\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"4385\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/code1-19\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1.jpg\" data-orig-size=\"1349,534\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793350502&quot;}\" data-image-title=\"Calculating the number of bits\" data-image-description=\"&lt;p&gt;Calculating the number of bits&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Calculating the number of bits&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1-1024x405.jpg\" class=\"wp-image-4385\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1.jpg?resize=600%2C238&#038;ssl=1\" alt=\"Calculating the number of bits\" width=\"600\" height=\"238\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1.jpg?resize=300%2C119&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1.jpg?resize=1024%2C405&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code1.jpg?w=1349&amp;ssl=1 1349w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-4385\" class=\"wp-caption-text\"><strong>Calculating the number of bits<\/strong><\/figcaption><\/figure>\n<p>In case we need to find out how many bits are set to 1, we can use the <em><strong>popcount<\/strong><\/em> function (line 18). Of course, the number of zeros will be the total bit width minus the number of 1 bits.<\/p>\n<p>Here is the output:<\/p>\n<figure id=\"attachment_4386\" aria-describedby=\"caption-attachment-4386\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output1.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"4386\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/output1-23\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output1.jpg\" data-orig-size=\"628,131\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793283512&quot;}\" data-image-title=\"Program output\" data-image-description=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output1.jpg\" class=\"wp-image-4386\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output1.jpg?resize=400%2C83&#038;ssl=1\" alt=\"Program output\" width=\"400\" height=\"83\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output1.jpg?resize=300%2C63&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output1.jpg?w=628&amp;ssl=1 628w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-4386\" class=\"wp-caption-text\"><strong>Program output<\/strong><\/figcaption><\/figure>\n<p>The next example is about bit representation. While guessing the bit representation is usually straightforward in the case of integers, what if we want to know how a floating point number is represented? We can use the convenient <em><strong>bit_cast<\/strong><\/em> function. Likewise, is there a way to determine if an integer is a power of 2? Both these are illustrated below:<\/p>\n<figure id=\"attachment_4387\" aria-describedby=\"caption-attachment-4387\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"4387\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/code2-21\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2.jpg\" data-orig-size=\"1136,308\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793350542&quot;}\" data-image-title=\"Finding bit representation\" data-image-description=\"&lt;p&gt;Finding bit representation&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Finding bit representation&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2-1024x278.jpg\" class=\"wp-image-4387\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2.jpg?resize=600%2C163&#038;ssl=1\" alt=\"Finding bit representation\" width=\"600\" height=\"163\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2.jpg?resize=300%2C81&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2.jpg?resize=1024%2C278&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code2.jpg?w=1136&amp;ssl=1 1136w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-4387\" class=\"wp-caption-text\"><strong>Finding bit representation<\/strong><\/figcaption><\/figure>\n<p>The program output is this:<\/p>\n<figure id=\"attachment_4388\" aria-describedby=\"caption-attachment-4388\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output2.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4388\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/output2-25\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output2.jpg\" data-orig-size=\"632,150\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793287538&quot;}\" data-image-title=\"Program output\" data-image-description=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output2.jpg\" class=\"wp-image-4388\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output2.jpg?resize=400%2C95&#038;ssl=1\" alt=\"Program output\" width=\"400\" height=\"95\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output2.jpg?resize=300%2C71&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output2.jpg?w=632&amp;ssl=1 632w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-4388\" class=\"wp-caption-text\"><strong>Program output<\/strong><\/figcaption><\/figure>\n<p>Another common operation we perform, especially with respect to decimal numbers is rounding up and down. Let us change the scenario slightly. Given an integer, we want to round it up (or round down) to the nearest power of two. The functions <em><strong>bit_ceil<\/strong><\/em> and <em><strong>bit_floor<\/strong><\/em> come to our rescue.<\/p>\n<figure id=\"attachment_4389\" aria-describedby=\"caption-attachment-4389\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4389\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/code3-13\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3.jpg\" data-orig-size=\"1323,309\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793350579&quot;}\" data-image-title=\"Nearest power of two\" data-image-description=\"&lt;p&gt;Nearest power of two&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Nearest power of two&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3-1024x239.jpg\" class=\"wp-image-4389\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3.jpg?resize=600%2C140&#038;ssl=1\" alt=\"Nearest power of two\" width=\"600\" height=\"140\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3.jpg?resize=300%2C70&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3.jpg?resize=1024%2C239&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code3.jpg?w=1323&amp;ssl=1 1323w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-4389\" class=\"wp-caption-text\"><strong>Nearest power of two<\/strong><\/figcaption><\/figure>\n<p>The above example also shows the use of the function <em><strong>byteswap<\/strong><\/em> that reverses the bytes of the given integer. Mind you &#8211; it is bytes, not bits! See line 42.<\/p>\n<p>Here is the output from the program:<\/p>\n<figure id=\"attachment_4390\" aria-describedby=\"caption-attachment-4390\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output3.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4390\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/output3-16\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output3.jpg\" data-orig-size=\"631,152\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793350654&quot;}\" data-image-title=\"Program output\" data-image-description=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output3.jpg\" class=\"wp-image-4390\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output3.jpg?resize=400%2C96&#038;ssl=1\" alt=\"Program output\" width=\"400\" height=\"96\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output3.jpg?resize=300%2C72&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output3.jpg?w=631&amp;ssl=1 631w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-4390\" class=\"wp-caption-text\"><strong>Program output<\/strong><\/figcaption><\/figure>\n<p>There are also the standard bit rotation functions &#8211; rotate left and rotate right. I am not covering them here.<\/p>\n<p>Finally, <em><strong>&lt;bit&gt;<\/strong><\/em> also has a clean mechanism to detect the <em><strong>\u201cendianness\u201d<\/strong><\/em> of the current platform. See the following example.<\/p>\n<figure id=\"attachment_4391\" aria-describedby=\"caption-attachment-4391\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code4.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4391\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/code4-6\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code4.jpg\" data-orig-size=\"744,280\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793532279&quot;}\" data-image-title=\"Finding endianness\" data-image-description=\"&lt;p&gt;Finding endianness&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Finding endianness&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code4.jpg\" class=\"wp-image-4391\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code4.jpg?resize=400%2C151&#038;ssl=1\" alt=\"Finding endianness\" width=\"400\" height=\"151\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code4.jpg?resize=300%2C113&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/code4.jpg?w=744&amp;ssl=1 744w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-4391\" class=\"wp-caption-text\"><strong>Finding endianness<\/strong><\/figcaption><\/figure>\n<p>My Windows machine is <em><strong>x64<\/strong><\/em> and I get <em><strong>\u201cLittle-endian\u201d<\/strong><\/em>. See below:<\/p>\n<figure id=\"attachment_4392\" aria-describedby=\"caption-attachment-4392\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output4.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4392\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2026\/11\/01\/exploring-c-bit-manipulation-functions\/output4-10\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output4.jpg\" data-orig-size=\"659,109\" data-comments-opened=\"1\" data-image-meta=\"{&quot;credit&quot;:&quot;Admin&quot;,&quot;created_timestamp&quot;:&quot;1793532240&quot;}\" data-image-title=\"Program output\" data-image-description=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Program output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output4.jpg\" class=\"wp-image-4392\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output4.jpg?resize=400%2C66&#038;ssl=1\" alt=\"Program output\" width=\"400\" height=\"66\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output4.jpg?resize=300%2C50&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/11\/output4.jpg?w=659&amp;ssl=1 659w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-4392\" class=\"wp-caption-text\"><strong>Program output<\/strong><\/figcaption><\/figure>\n<p>The <em><strong>&lt;bit&gt;<\/strong><\/em> header thus has a collection of useful functions frequently used by low-level programmers. Of course, there may be more operations that are needed as part of bit manipulation, but those can be implemented on top of the existing functions.<\/p>\n<p>Have a nice weekend and a great week ahead!<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>You can download the source code <a href=\"https:\/\/www.rangakrish.com\/downloads\/BitsExample.cpp\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Developers who work on low-level programming in C++, for example controlling IoT devices, know the importance of bit manipulation. Prior to C++20, we wrote our own set of functions according to our specific requirements. C++20 introduced &lt;bit&gt; header and this was later improved in C++23. The current set of functions provide substantial functionality. In today\u2019s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[49,17],"tags":[466,67],"class_list":["post-4384","post","type-post","status-publish","format-standard","hentry","category-c","category-programming","tag-bit-manipulation","tag-c"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-18I","jetpack-related-posts":[{"id":3017,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/02\/16\/calling-external-dll-functions-from-julia\/","url_meta":{"origin":4384,"position":0},"title":"Calling External DLL Functions from Julia","author":"admin","date":"February 16, 2023","format":false,"excerpt":"Julia supports calling external functions, especially those written in \u201cC\u201d language. As Julia documentation says, such calls do not involve any \u201cboilerplate\u201d code and hence are efficient. In today\u2019s article, I am going to show how to call functions defined in a DLL (Windows 64 bit). Instead of using direct\u2026","rel":"","context":"In &quot;Julia&quot;","block_context":{"text":"Julia","link":"https:\/\/www.rangakrish.com\/index.php\/category\/julia\/"},"img":{"alt_text":"The \"lispEval\" Function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/02\/code-300x117.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/02\/code-300x117.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/02\/code-300x117.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2057,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/07\/19\/calling-lisp-functions-from-elixir\/","url_meta":{"origin":4384,"position":1},"title":"Calling Lisp Functions from Elixir","author":"admin","date":"July 19, 2020","format":false,"excerpt":"In the last article\u00a0I showed how we can simulate the idea of Lisp's \"closure\" in Elixir. Today, I would like to demonstrate how we can call Lisp functions from Elixir using the NIF interface. What is the need to integrate Elixir with another language? I can think of two reasons:\u2026","rel":"","context":"In &quot;Elixir&quot;","block_context":{"text":"Elixir","link":"https:\/\/www.rangakrish.com\/index.php\/category\/elixir\/"},"img":{"alt_text":"Using the Lisp Functions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3070,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/04\/02\/building-v-language-dll\/","url_meta":{"origin":4384,"position":2},"title":"Building V Language DLL","author":"admin","date":"April 2, 2023","format":false,"excerpt":"The relatively new V Programming Language (Vlang) boasts of some interesting features such as \u201cfast compilation\u201d and runtime performance \u201cas fast as C\u201d, at the same time being a \u201csimple language\u201d. As I normally do with other languages that I learn and use, I decided to see how easy it\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"V Program","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/04\/V-source-267x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1946,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/03\/28\/stdis_empty\/","url_meta":{"origin":4384,"position":3},"title":"std::is_empty","author":"admin","date":"March 28, 2020","format":false,"excerpt":"In the previous post, we looked at the std::is_destructible<T> type trait. Today, let us try to understand another type trait std::is_empty<T>. As per the specification, is_empty<T>::value will return true in the following cases: - The class\/struct has no non-static data member - The class\/struct does not define a virtual function\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"Example4: Union and Bit Field","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/03\/Example4-1.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/03\/Example4-1.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/03\/Example4-1.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2789,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/05\/04\/using-dll-functions-in-rust\/","url_meta":{"origin":4384,"position":4},"title":"Using DLL Functions in Rust","author":"admin","date":"May 4, 2022","format":false,"excerpt":"When you program in Rust, especially in a non-trivial project, there is a good chance that you will need to call \"external\" functions (usually, C\/C++) that are available in a DLL (we are talking about the Windows platform here). It could be because you wish to re-use some code that\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"New DLL Project","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/05\/DLL-Project-300x211.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/05\/DLL-Project-300x211.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/05\/DLL-Project-300x211.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3106,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/05\/13\/stdexpected\/","url_meta":{"origin":4384,"position":5},"title":"std::expected","author":"admin","date":"May 13, 2023","format":false,"excerpt":"I had written about std::optional<> in an earlier article. C++23 introduces std::expected<> as an interesting extension to std::optional<>. Whereas std::optional<> contains a value or none at all, std::expected<> contains a value or an error code associated with it. This gives better control to the caller in terms of handling the\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"An Example","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/05\/source1-300x265.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/05\/source1-300x265.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/05\/source1-300x265.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/4384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=4384"}],"version-history":[{"count":6,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/4384\/revisions"}],"predecessor-version":[{"id":4400,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/4384\/revisions\/4400"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=4384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=4384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=4384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}