Here i explore the use of advanced template techniques in C++, including class template argument deduction, smart pointers, structs, classes, abstract classes, virtual functions, auto
, lambda
, and constexpr
.
The goal of this repository is for me to learn about modern template techniques in C++ and to serve as a resource ot other C++ developers looking to improve their template programming skills.
The repo contains various examples that illustrate different advanced template techniques and their use cases. Each example is well commented and easy to understand.
C++17's class template argument deduction feature to deduce template arguments from constructor parameters.
Smart pointers to manage the lifetime of objects in class templates and structs.
Structs and classes in template programming being used together.
Combination of abstract classes and virtual functions in template programming.
auto
and lambda can be used in conjunction with templates to make code more concise and expressive.
constexpr
to make template code more efficient at runtime and during compile-time.
The examples in this repository are personal reference, with each example covering a specific concept.
basic understanding of template programming in C++ before diving into the example.
I welcome contributions to this repository. If you have an example of an advanced template technique that you would like to add, please open a pull request.
- Denis Murphy
This repository is licensed under the MIT license.