We will analyse such code
#include
template
class SomeClass {
public:
T getValue() { return value; }
private:
T value = {};
U* ptr = nullptr;
};
int main() {
SomeClass sc;
std::cout << sc.getValue() << std::endl;
return 0;
}
template
class A {}; // primary template
template
class A {}; // #1: partial specialization where T2 is a pointer to T1
template
class A {}; // #2: partial specialization where T1 is a pointer
template
class A {}; // #3: partial specialization where T1 is int, I is double,
// and T2 is a pointer
template
class A {}; // #4: partial specialization where T2 is a pointer
Your abilities after Templates – Basics training
- can read and understand the code with function and class templates
- can write universal and generic code with function and class templates
- know how to specialize templates
- know how to partially specialize template classes and variables
- know when to avoid template specialization
- know the overload resolution rules and can predict which overload will be called
Agenda
- intro and pre-test
- function templates
- type traits library
- class templates
- specializations
- overload resolution rules
- partial specializations
- variable templates
- recap
Activities
- pre-work to be done before our training
- pre-test pre-test at the beginning
- exercises followed by trainers implementation
- coding dojo
- participants solutions code review
- post-work with code review
- post-test one week after the training
- certificate of completion
Duration
- 1 day (7 hours with breaks)
Form
- online
- classroom