News for hackers. Stuff that matters.
Re:My Most Important C++ Aha Moments (2006) by kazinator on Sunday June 26, 2016 @10:20AM (#11980898)
Alternative view: if you must use C++, stick to nothing later than C++2003.

Anyway, declaring a constructor " = delete" isn't the same thing as making it private. If it's private, the code in your class scope can still use it. If you can't trust your class private code to do things correctly, then you're screwed; go join IT and write backup shell scripts. So basically this "= delete" is just another ear growing out of the elbow of C++.

Re:My Most Important C++ Aha Moments (2006) by prodigal_erik on Sunday June 26, 2016 @03:47PM (#11982337)
The reason for testing and static typing is that you can't trust yourself to be perfect. I want to declare that I won't do things that don't make sense, so the tools will tell me if I do them unintentionally.
Re:My Most Important C++ Aha Moments (2006) by kazinator on Sunday June 26, 2016 @08:43PM (#11983580)
In 1998 C++, we can solve the problem of how to make a class non-copyable, even to code that is in its class scope.

We can create a dummy class which has a private copy constructor that is not implemented:

  class noncopyable {
  private:
    noncopyable(const noncopyable &);
  };
then simply make this a data member of a class that you don't wish to be copyable:

  class whatever {
  private:
    noncopyable nc;
  };
The default copy constructor generated by the C++ compiler performs a member-for-member copy, which involves copying nc. That is not possible, so in effect that copy constructor is defeated, not unlike by "= delete".

Alternatively use inheritance to mix this in as a trait:

  class whatever : private noncopyable {
    // ...
  };
Re:My Most Important C++ Aha Moments (2006) by mratzloff on Sunday June 26, 2016 @10:46AM (#11981005)
Why?