News for hackers. Stuff that matters.
Re:C++ Patterns: The Badge by w0utert on Wednesday June 12, 2019 @04:24AM (#20162742)
I like this idea, except for the fact that the extra parametrer pollutes the method signature and method calls, for something that really should only be a compile-time directive.

I'm actually curious why something like this has never been included as a language feature, it seems trivial to come up with a syntax for fine-grained access control, that is fully backwards-compatible and a true zero-cost abstraction.

Most obvious first shot:

  class A
  {
    private:
      void badgedFunction() const friend Device, SomeOtherClass;
  };
Did you ever check with the C++ working group if there are any proposals for language extensions for this purpose?
Re:C++ Patterns: The Badge by akling on Wednesday June 12, 2019 @04:37AM (#20162798)
Yeah, polluting the signatures is a shame.

I've only just decided that I enjoy using this pattern so my internal standards committee hadn't progressed to the proposal stage yet. :)

Your syntax makes perfect sense to me, and I think it would make a great addition to the language. I wonder what the real working group would say. (I tried quickly googling for something that might sound like an existing proposal but came up empty.)