WPILibC++  unspecified
Base.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5
11 static_assert(0,
12  "GCC must be 5 or greater. If building for the roboRIO, please "
13  "update to the 2018 toolchains.");
14 #endif
15 
16 #if defined(_MSC_VER) && _MSC_VER < 1900
17 static_assert(0, "Visual Studio 2015 or greater required.");
18 #endif
19 
20 #include <HAL/cpp/make_unique.h>
21 
22 #define DEFAULT_MOVE_CONSTRUCTOR(ClassName) ClassName(ClassName&&) = default
23 
24 namespace frc {
25 
26 // A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
27 // that is being deleted by someone else.
28 template <class T>
29 struct NullDeleter {
30  void operator()(T*) const noexcept {};
31 };
32 
33 } // namespace frc
34 
35 #include <atomic>
36 
37 namespace frc {
38 
39 // Use this for determining whether the default move constructor has been
40 // called on a containing object. This serves the purpose of allowing us to
41 // use the default move constructor of an object for moving all the data around
42 // while being able to use this to, for instance, chose not to de-allocate
43 // a PWM port in a destructor.
44 struct HasBeenMoved {
45  HasBeenMoved(HasBeenMoved&& other) {
46  other.moved = true;
47  moved = false;
48  }
49  HasBeenMoved() = default;
50  std::atomic<bool> moved{false};
51  operator bool() const { return moved; }
52 };
53 
54 } // namespace frc
55 
56 // For backwards compatibility
57 #ifndef NAMESPACED_WPILIB
58 using namespace frc; // NOLINT
59 #endif
Definition: RobotController.cpp:14
Definition: Base.h:29
Definition: Base.h:44