News for hackers. Stuff that matters.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by rumcajz on Thursday August 30, 2012 @01:17PM (#4455656)
Yup. It's possible to do that. My point was that if you want to do that you break the encapsulation, i.e. contained object would have to know about its container(s). This applies to Boost intrusive lists as well AFAICS.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by scott_s on Thursday August 30, 2012 @01:22PM (#4455686)
Which is entirely true, and is often the case when performance is a goal - abstractions must be broken. But that is not an argument for or against C++.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by rumcajz on Thursday August 30, 2012 @01:33PM (#4455735)
I've given an example of the language extension that would solve the problem at the end of the article.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by scott_s on Thursday August 30, 2012 @01:50PM (#4455823)
C++ already allows such a thing using the "curiously recurring template pattern" (http://en.wikipedia.org/wiki/Curiously_recurring_template_pa...), often now called "mixins":

  class person
  {
  protected:
      int age;
      int wieght;
  };

  template <class Base>
  class people: public Base
  {
  private:
      Base *prev;
      Base *next;
  };

  people<person> plist;
Re:Why should I have written ZeroMQ in C, not C++ (part II) by tedunangst on Thursday August 30, 2012 @02:06PM (#4455898)
Your language extension sounds a lot like the friend keyword.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by scott_s on Thursday August 30, 2012 @02:26PM (#4456022)
That's what I thought at first, but friend is for when you want class A to be able to view private things of class B. That is, B needs to know ahead of time what A is interested in. He wants B to remain ignorant of what A wants - he wants A to be able to insert new fields into B. But we can accomplish the same thing with mixins.