<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>C/C++ on Naresh Mehta</title><link>https://naresh.se/en/categories/c/c++/</link><description>Recent content in C/C++ on Naresh Mehta</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>naresh.mehta@gmail.com (Naresh Mehta)</managingEditor><webMaster>naresh.mehta@gmail.com (Naresh Mehta)</webMaster><copyright>&amp;copy;{year}, All Rights Reserved</copyright><lastBuildDate>Mon, 03 Apr 2017 12:29:29 +0200</lastBuildDate><sy:updatePeriod>weekly</sy:updatePeriod><atom:link href="https://naresh.se/en/categories/c/c++/index.xml" rel="self" type="application/rss+xml"/><item><title>Ranged Switch Case C++</title><link>https://naresh.se/en/posts/2017/3461/</link><pubDate>Mon, 03 Apr 2017 12:29:29 +0200</pubDate><author>naresh.mehta@gmail.com (Naresh Mehta)</author><atom:modified>Wed, 16 Apr 2025 18:13:58 +0200</atom:modified><guid>https://naresh.se/en/posts/2017/3461/</guid><description>&lt;h2 id="ranges-in-c-switch-case-block"&gt;Ranges in C++ Switch Case block&lt;/h2&gt;
&lt;p&gt;Today, we will do something really stupid! Yes, I am talking about the ranged switch case support that is available in C++. In all the commercial/hobby source code that I have seen, implemented and used, rarely have I come across the ranged switch case use. Most of the code when in need of ranges inside a switch case start using multiple case cascading or (the more niche programmers) resorting to nested if..else blocks!&lt;br /&gt;
So much so that when I told one of my co-workers that we can use ranges in C++ switch case, he started laughing (hysterically if I may add). Taken aback, I wanted to see if I have learned stuff wrong. So here it is, just to brush up your basic cpp knowledge and fall in love with it again! Below is the code in ideone ready for you to take for a spin.&lt;/p&gt;</description><dc:creator>Naresh Mehta</dc:creator><category>c/c++</category></item></channel></rss>