Comment

Comment by mkettn

whats the advantage over declaring register_device as a functor object from an anon class? for example:

  class Device;
  class VFS {
  public:
   class {
   friend Device;
   void operator()(int y) {/* do stuff with y here*/}}     register_device;
  };
  class Device {
  public:
   void foo(VFS fs) {
    fs.register_device(1);
   }
  };
  
  int main(int argc, char *argv[]) {
  // fails:
  // VFS().register_device(2);
  // works:
   Device().foo(VFS());
   return 0;
  }
and no need for a badge class (erm... well but an anon class).

my c++ skills are a bit rusty, because most of the time python works just fine.

parent mkettn 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton