<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Templates on Siddharth Mishra</title><link>http://brightprogrammer.in/tags/templates/</link><description>Recent content in Templates on Siddharth Mishra</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 14 Jun 2026 21:53:10 -0700</lastBuildDate><atom:link href="http://brightprogrammer.in/tags/templates/index.xml" rel="self" type="application/rss+xml"/><item><title>OnlyGenerics In C</title><link>http://brightprogrammer.in/posts/onlygenerics-in-c/</link><pubDate>Wed, 25 Mar 2026 00:00:00 +0000</pubDate><guid>http://brightprogrammer.in/posts/onlygenerics-in-c/</guid><description>&lt;h1 id="introduction">Introduction&lt;/h1>
&lt;p>C doesn’t have templates, but it does have the preprocessor. If you’re careful, you can get
something that feels like &lt;code>std::vector&amp;lt;T&amp;gt;&lt;/code> without switching languages. It’s not perfect and it’s
not type theory, but it is surprisingly usable.&lt;/p>
&lt;p>This post is about that: cheap macro tricks that give you “templated” types in plain C.&lt;/p>
&lt;h1 id="the-core-trick">The Core Trick&lt;/h1>
&lt;p>You first define a generic backing struct. Then you create a macro that expands to a type‑specific
struct. That macro is your “template”.&lt;/p></description></item></channel></rss>