News for hackers. Stuff that matters.
Re:Comparing C and C++ usage and performance with a real wor... by andrepd on Sunday September 03, 2017 @02:03PM (#15162836)
That is absolutely false. C++ member functions are zero-cost abstractions, i.e. they have the same cost as any other function call. Member functions are _not_ function pointers that reside inside the struct. They don't take up space, they don't need dereferencing to call. They are just "syntatic sugar" to group functions more logically.
Re:Comparing C and C++ usage and performance with a real wor... by inetknght on Sunday September 03, 2017 @02:36PM (#15163033)
> Member functions are _not_ function pointers that reside inside the struct.

...as long as they're not virtual functions, this is correct. Add a virtual table and this is less correct (but the optimizer may still make it correct if it can prove the types match).

Re:Comparing C and C++ usage and performance with a real wor... by andrepd on Sunday September 03, 2017 @02:42PM (#15163066)
Yes, that is correct, but then again virtual functions give you new functionality, namely dynamic dispatching. Stick with static inheritance and you won't have this overhead.
Re:Comparing C and C++ usage and performance with a real wor... by khitchdee on Sunday September 03, 2017 @02:41PM (#15163058)
Please check your facts. C++ member functions are not as simple as function pointers inside structs.
Re:Comparing C and C++ usage and performance with a real wor... by Narishma on Monday September 04, 2017 @03:31AM (#15166404)
You're right, they are simpler in fact. They have the same cost as free-standing functions.
Re:Comparing C and C++ usage and performance with a real wor... by khitchdee on Monday September 04, 2017 @03:38AM (#15166426)
Right. As is speech -- free.