<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cs on 我的博客</title><link>https://quhongbin.github.io/tags/cs/</link><description>Recent content in Cs on 我的博客</description><generator>Hugo</generator><language>zh-CN</language><atom:link href="https://quhongbin.github.io/tags/cs/index.xml" rel="self" type="application/rss+xml"/><item><title>C++ Templates</title><link>https://quhongbin.github.io/posts/1/01/c-templates/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://quhongbin.github.io/posts/1/01/c-templates/</guid><description>&lt;h1 id="c-templates"&gt;C++ Templates&lt;/h1&gt;&#10;&lt;p&gt;Templates are C++'s mechanism for &lt;strong&gt;generic programming&lt;/strong&gt; &amp;mdash; writing&#10;code that works with any type without repeating yourself. Unlike runtime&#10;polymorphism (virtual functions), templates are resolved entirely at&#10;compile time: the compiler generates a separate copy of the function or&#10;class for each set of type arguments actually used. This is called&#10;&lt;strong&gt;template instantiation&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;Templates are the foundation of the C++ Standard Library:&#10;&lt;code&gt;std::vector&amp;lt;int&amp;gt;&lt;/code&gt;, &lt;code&gt;std::map&amp;lt;std::string, double&amp;gt;&lt;/code&gt;,&#10;&lt;code&gt;std::sort(begin, end)&lt;/code&gt; &amp;mdash; all templates. They power everything from&#10;containers to algorithms to smart pointers. Understanding templates&#10;deeply means understanding how modern C++ achieves its combination of&#10;abstraction and zero-overhead performance.&lt;/p&gt;</description></item></channel></rss>