Member-only story

Advanced Study of Effective Moδ C++

Beck Moulton
17 min readMay 30, 2024

--

Introduction

As a programmer with aspirations, one must hope to write the most perfect and impeccable code. As for the standard of perfection, I think different designers will have their own set of standards. In actual coding, how to improve personal standards and gain recognition from colleagues requires continuous accumulation. To accumulate, one must start from the details, observe excellent code, learn existing frameworks, and draw on the wisdom left by predecessors.

This is a note after reading Effective Mominbi C++, written by Scott Meyers, one of the world's leading experts in C++ technology, to help developers better understand and apply the features and best practices of modern C++. The book is Scott Meyers's sequel to Effective C++ and More Effective C++, and provides in-depth explanations of the new features introduced in C++ 11, C++ 14, and C++ 17.

1. Understand template type derivation

Template type deduction refers to the compiler inferring the type of the template parameter from the type of the function parameter, thereby determining the instantiation type of the function template. In some cases, ParamType is not the same as the function parameter type, but is derived based on the parameter type (emphasis)

Use templates:

template<typename T>
void f(ParamType param); // ParamType 写法上包含Tf(expr); // 从expr推导ParamType和T

--

--

Beck Moulton
Beck Moulton

Written by Beck Moulton

Focus on the back-end field, do actual combat technology sharing Buy me a Coffee if You Appreciate My Hard Work https://www.buymeacoffee.com/BeckMoulton

No responses yet