mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Add move constructors and assignment operators to wpilibc (#1314)
Fixes #898.
This commit is contained in:
committed by
Peter Johnson
parent
b1965f74a8
commit
1aa8446725
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user