News for hackers. Stuff that matters.
Re:Inheritance was invented as a performance hack by josephg on Thursday May 08, 2025 @08:52AM (#43925617)
Composition. Sorry about the syntax - its been awhile since I wrote C++.

    class<T> IntrusiveListNode { T* next, T* prev }

    class SomeObj {
        IntrusiveListNode<SomeObj> list_foo;
        IntrusiveListNode<SomeObj> list_bar;
    }
Re:Inheritance was invented as a performance hack by codr7 on Thursday May 08, 2025 @08:58AM (#43925678)
Ah, of course; templates and linking the full object.

Thanks for the update, my C++ is pretty rusty.

But it brings up another problem for me; when iterating a list like that, how do you know which of the links to follow? I get that you can do it manually step by step, but if you wanted to say write an iterator. Member pointers?