Is there a case where pass-by-reference is more expensive than pass-by-value in C++? If so, what would that case be?
Is there a case where pass-by-reference is more expensive than pass-by-value in C++? If
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Prefer passing primitive types (int, char, float, …) and POD structs that are cheap to copy (Point, complex) by value.
This will be more efficient than the indirection required when passing by reference.
See Boost’s Call Traits.