Category

Templates

Function Templates

A template is a pattern the compiler uses to expand into actual code. Rather than writing out a completed function yourself, you write a general outline contain…

Jul 15, 2026 →

Class Templates

One most used example is when you need to have a pair of values of the same type. It is just too frequent to write a struct for each type. Here's what we get fo…

Jul 15, 2026 →

Template Argument Deduction

When a function template is invoked, the compiler is often able to deduce the template type by itself. That process is called template argument deduction. It al…

Jul 15, 2026 →

Non-Type Template Parameters

While most template parameters are types, a template can also take ordinary non type values that are known at compile time. Those non type template parameters a…

Jul 15, 2026 →

Template Specialization

Sometimes a generic template does the wrong thing for a single specific type. It's necessary for the compiler to have a function or a class for this specific ty…

Jul 15, 2026 →

Variadic Templates

Writing a function template that accepts exactly two arguments is straightforward, but useful operations often take three, or four, or many. It’s unfeasible to…

Jul 15, 2026 →

Parameter Packs and Fold Expressions

A parameter pack is simply a collection of zero or more template arguments that the compiler treats as a single entity. Whatever they are, something then has to…

Jul 15, 2026 →

Type Traits

A type trait is a simple template that, during compilation, provides an answer to a question concerning a type. The answer is a type or a Boolean value that oth…

Jul 15, 2026 →

SFINAE

A template that looks correct may fail if the compiler tries to substitute a particular type into it. Under normal rules, the failure would be a hard error and…

Jul 15, 2026 →
About CppLearn

CppLearn is an interactive, free reference for modern C++. In each lesson, you'll find out how the language works, rather than just lines of code that you can copy and paste. We cover concepts starting from beginner lessons on fundamentals and proceed to templates, move semantics, smart pointers, and areas that usually trap or scare C++ learners.