I need a way to force calling a constant version of member function. I’m trying to make it efficient as possible. Any good solutions?
EDIT: looking for a generic function
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.
Make a reference to a const Type, or a pointer to a const Type.
You can do that in a fancy way, but at the end of the day, that’s the only way.
Though really I don’t see what the purpose of this is. Seems like it’s not worth the effort.
Also, I’m not quite sure I understand what you mean by a generic function. That needs some clarification, but if I understand correctly, you want to take a pointer/value/reference and pass it to a function and have it magically call a const method? That would only work if polymorphism or at least a method of the same name (templating) could be used.