Which Parameter Type Should I Use?
In this article, we’ll discuss a small but practical question: when should you use each kind of function parameter type? Classifying Parameters Suppose we have a type T (to keep things simple, T here is not a generic type parameter). How many ways are there to pass a parameter of this type to a function? Let’s break it down: Qualifier: const-qualified or not Reference category: by value, by lvalue reference, by rvalue reference Based on this classification, we get exactly 5 parameter types:...