<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Loops on Jeanphilo Blog</title><link>https://shio-chan-dev.github.io/jeanblog/tags/loops/</link><description>Recent content in Loops on Jeanphilo Blog</description><generator>Hugo -- 0.159.2</generator><language>en-us</language><lastBuildDate>Tue, 30 Dec 2025 18:12:00 +0800</lastBuildDate><atom:link href="https://shio-chan-dev.github.io/jeanblog/tags/loops/index.xml" rel="self" type="application/rss+xml"/><item><title>What Is size_t? Why C++ Loops Prefer size_t Over int</title><link>https://shio-chan-dev.github.io/jeanblog/dev/c++/size_t-why-not-int-loop/</link><pubDate>Tue, 30 Dec 2025 18:12:00 +0800</pubDate><guid>https://shio-chan-dev.github.io/jeanblog/dev/c++/size_t-why-not-int-loop/</guid><description>&lt;h1 id="what-is-size_"&gt;&lt;strong&gt;What Is size_t? Why C++ Loops Prefer size_t Over int&lt;/strong&gt;&lt;/h1&gt;
&lt;h3 id="subtitle--abstract"&gt;Subtitle / Abstract&lt;/h3&gt;
&lt;p&gt;When you iterate containers with a &lt;code&gt;for&lt;/code&gt; loop, &lt;code&gt;size_t&lt;/code&gt; is often safer and closer to the intended meaning than &lt;code&gt;int&lt;/code&gt;. This post uses the ACERS structure to explain what &lt;code&gt;size_t&lt;/code&gt; is, why it is used, the common pitfalls, and practical patterns for production C++.&lt;/p&gt;
&lt;h3 id="meta"&gt;Meta&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Reading time: 8-10 minutes&lt;/li&gt;
&lt;li&gt;Tags: C++, size_t, type system, loops, STL&lt;/li&gt;
&lt;li&gt;SEO keywords: size_t usage, size_t vs int, C++ loop initialization, size_t underflow&lt;/li&gt;
&lt;li&gt;Meta description: Explain size_t and why loops often use it, with safe patterns and engineering scenarios.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="target-readers"&gt;Target readers&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;C++ beginners who are new to &lt;code&gt;size_t&lt;/code&gt;, &lt;code&gt;sizeof&lt;/code&gt;, and container &lt;code&gt;size()&lt;/code&gt; return types&lt;/li&gt;
&lt;li&gt;Mid-level engineers who have seen &lt;code&gt;-Wsign-compare&lt;/code&gt; warnings or unsigned underflow bugs&lt;/li&gt;
&lt;li&gt;Engineers writing cross-platform or high-performance C++&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="background--motivation"&gt;Background / Motivation&lt;/h3&gt;
&lt;p&gt;In C++ code, you often see loops like:&lt;/p&gt;</description></item></channel></rss>