015 - The Most Effective Way of Learning C++ Types, auto, auto&, auto&&, decltype, decltype(auto)

preview_player
Показать описание
Rule of Thumbs:
1. Use auto for iterators in the STL algorithms.
2. Use auto& to enumerate elements of STL containers in the ranged-for.
3. Use auto&& as the parameter types of lambdas.

4. Use auto as return type when we return an instance using copy-semantic
or internally move semantic.

For example, we can use auto as return type when we return
an instance of shared_ptr or unique_ptr

5. Use auto& as return type when we return a data member of a class from
a member function.

6. Use auto&& as return type when we return an rvalue reference from an operator function.

7. Use decltype(auto) as return type when Rule 4, 5, 6 are not suitable.


Template Metaprogramming 30 - auto, auto&, auto&&, decltype, decltype(auto)

Template Metaprogramming 31 - Type Decay and Perfect Forwarding

Useful resources

Prerequisites:

014 - Must-Know Must-Understand Type Function - std::remove_cvref_t

013 - Understanding and Extending C++ Standard Template Library - is_same_v

012 - How to Use Function Pointer, Function Alias with using and typedef

000 - Install Microsoft Visual Studio, GNU g++, clang++, Intel TBB

Download Source Code:


Episode 015

Episode 014

Episode 013

Episode 012
Рекомендации по теме
Комментарии
Автор

Thankyou Kim for your remarkable contribution and teachings in C++.

Rakeshkumar-poyg
Автор

Template Metaprogramming series are the first series that I watched.
Now 4 months passed and I have watched almost all of your C++ related videos.
They helped me a lot and thank you so much for sharing these.
Much obliged, Mr. Kim!

hankchang
Автор

Hi Thomas Kim, I have been follow you since 2020/21 with some gaps. I have two questions: Why change your name to @IQ95 The Homo Siliconiens and how do I became member of yours because some videos didn't play if you are not member?

pezalot
join shbcf.ru