- // Default ctor provided explicitly as it is not provided implicitly due to
- // the presence of the (deleted) copy ctor above.
- ArgList() { }
- // Virtual to provide a vtable anchor and because -Wnon-virtua-dtor warns, not
- // because this type is ever actually destroyed polymorphically.
- virtual ~ArgList();
+ // Make the default special members protected so they won't be used to slice
+ // derived objects, but can still be used by derived objects to implement
+ // their own special members.
+ ArgList() = default;
+ // Explicit move operations to ensure the container is cleared post-move
+ // otherwise it could lead to a double-delete in the case of moving of an
+ // InputArgList which deletes the contents of the container. If we could fix
+ // up the ownership here (delegate storage/ownership to the derived class so
+ // it can be a container of unique_ptr) this would be simpler.
+ ArgList(ArgList &&RHS) : Args(std::move(RHS.Args)) { RHS.Args.clear(); }
+ ArgList &operator=(ArgList &&RHS) {
+ Args = std::move(RHS.Args);
+ RHS.Args.clear();
+ return *this;
+ }
+ // Protect the dtor to ensure this type is never destroyed polymorphically.
+ ~ArgList() = default;