Add move constructors and assignment operators to wpilibc (#1314)

Fixes #898.
This commit is contained in:
Tyler Veness
2018-09-24 00:08:25 -07:00
committed by Peter Johnson
parent b1965f74a8
commit 1aa8446725
136 changed files with 764 additions and 89 deletions

View File

@@ -17,8 +17,6 @@ static_assert(0,
static_assert(0, "Visual Studio 2015 or greater required.");
#endif
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName) ClassName(ClassName&&) = default
/** WPILib FRC namespace */
namespace frc {
@@ -31,27 +29,6 @@ struct NullDeleter {
} // namespace frc
#include <atomic>
namespace frc {
// Use this for determining whether the default move constructor has been
// called on a containing object. This serves the purpose of allowing us to
// use the default move constructor of an object for moving all the data around
// while being able to use this to, for instance, chose not to de-allocate
// a PWM port in a destructor.
struct HasBeenMoved {
HasBeenMoved(HasBeenMoved&& other) {
other.moved = true;
moved = false;
}
HasBeenMoved() = default;
std::atomic<bool> moved{false};
operator bool() const { return moved; }
};
} // namespace frc
// For backwards compatibility
#ifdef NO_NAMESPACED_WPILIB
using namespace frc; // NOLINT