WPILibC++
unspecified
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Base.h
1
/*----------------------------------------------------------------------------*/
2
/* Copyright (c) 2008-2017 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
#include <HAL/cpp/make_unique.h>
11
12
// MSVC 2013 doesn't allow "= default" on move constructors, but since we are
13
// (currently) only actually using the move constructors in non-MSVC situations
14
// (ie, wpilibC++Devices), we can just ignore it in MSVC.
15
#if defined(_MSC_VER) && _MSC_VER < 1900
16
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName)
17
#else
18
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName) ClassName(ClassName&&) = default
19
#endif
20
21
#if defined(_MSC_VER) && _MSC_VER < 1900
22
#define constexpr const
23
#endif
24
25
#if (__cplusplus < 201103L) && !defined(_MSC_VER)
26
#define nullptr NULL
27
#endif
28
29
#if defined(_MSC_VER) && _MSC_VER < 1900
30
#define noexcept throw()
31
#endif
32
33
// Provide std::decay_t when using GCC < 4.9
34
#if defined(__GNUC__)
35
#if __GNUC__ == 4 && __GNUC_MINOR__ < 9
36
#include <type_traits>
37
namespace
std
{
38
template
<
class
T>
39
using
decay_t =
typename
decay<T>::type;
40
}
// namespace std
41
#endif
42
#endif
43
44
namespace
frc
{
45
46
// A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
47
// that is being deleted by someone else.
48
template
<
class
T>
49
struct
NullDeleter
{
50
void
operator()(T*)
const
noexcept {};
51
};
52
53
}
// namespace frc
54
55
#include <atomic>
56
57
namespace
frc
{
58
59
// Use this for determining whether the default move constructor has been
60
// called on a containing object. This serves the purpose of allowing us to
61
// use the default move constructor of an object for moving all the data around
62
// while being able to use this to, for instance, chose not to de-allocate
63
// a PWM port in a destructor.
64
struct
HasBeenMoved
{
65
HasBeenMoved
(
HasBeenMoved
&& other) {
66
other.moved =
true
;
67
moved =
false
;
68
}
69
HasBeenMoved
() =
default
;
70
std::atomic<bool> moved{
false
};
71
operator
bool()
const
{
return
moved; }
72
};
73
74
}
// namespace frc
75
76
// For backwards compatibility
77
#ifndef NAMESPACED_WPILIB
78
using namespace
frc
;
// NOLINT
79
#endif
frc
Definition:
Timer.cpp:18
std
Definition:
json.cpp:1170
frc::NullDeleter
Definition:
Base.h:49
frc::HasBeenMoved
Definition:
Base.h:64
build
cppSource
wpilibc
headers
Base.h
Generated on Sat Oct 28 2017 21:17:16 for WPILibC++ by
1.8.11