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