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 #define DEFAULT_MOVE_CONSTRUCTOR(ClassName) ClassName(ClassName&&) = default
21 
22 namespace frc {
23 
24 // A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
25 // that is being deleted by someone else.
26 template <class T>
27 struct NullDeleter {
28  void operator()(T*) const noexcept {};
29 };
30 
31 } // namespace frc
32 
33 #include <atomic>
34 
35 namespace frc {
36 
37 // Use this for determining whether the default move constructor has been
38 // called on a containing object. This serves the purpose of allowing us to
39 // use the default move constructor of an object for moving all the data around
40 // while being able to use this to, for instance, chose not to de-allocate
41 // a PWM port in a destructor.
42 struct HasBeenMoved {
43  HasBeenMoved(HasBeenMoved&& other) {
44  other.moved = true;
45  moved = false;
46  }
47  HasBeenMoved() = default;
48  std::atomic<bool> moved{false};
49  operator bool() const { return moved; }
50 };
51 
52 } // namespace frc
53 
54 // For backwards compatibility
55 #ifdef NO_NAMESPACED_WPILIB
56 using namespace frc; // NOLINT
57 #endif
Definition: Utility.cpp:119
Definition: Base.h:27
Definition: Base.h:42