mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
ArrayRef: Add portability checks for constexpr.
This commit is contained in:
@@ -16,6 +16,29 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef LLVM_CONSTEXPR
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# if _MSC_VER >= 1900
|
||||||
|
# define LLVM_CONSTEXPR constexpr
|
||||||
|
# else
|
||||||
|
# define LLVM_CONSTEXPR
|
||||||
|
# endif
|
||||||
|
# elif defined(__has_feature)
|
||||||
|
# if __has_feature(cxx_constexpr)
|
||||||
|
# define LLVM_CONSTEXPR constexpr
|
||||||
|
# else
|
||||||
|
# define LLVM_CONSTEXPR
|
||||||
|
# endif
|
||||||
|
# elif defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
# define LLVM_CONSTEXPR constexpr
|
||||||
|
# elif defined(__has_constexpr)
|
||||||
|
# define LLVM_CONSTEXPR constexpr
|
||||||
|
# else
|
||||||
|
# define LLVM_CONSTEXPR
|
||||||
|
# endif
|
||||||
|
# define DEFINED_LLVM_CONSTEXPR
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
/// ArrayRef - Represent a constant reference to an array (0 or more elements
|
/// ArrayRef - Represent a constant reference to an array (0 or more elements
|
||||||
@@ -84,7 +107,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// Construct an ArrayRef from a C array.
|
/// Construct an ArrayRef from a C array.
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
/*implicit*/ constexpr ArrayRef(const T (&Arr)[N])
|
/*implicit*/ LLVM_CONSTEXPR ArrayRef(const T (&Arr)[N])
|
||||||
: Data(Arr), Length(N) {}
|
: Data(Arr), Length(N) {}
|
||||||
|
|
||||||
/// Construct an ArrayRef from a std::initializer_list.
|
/// Construct an ArrayRef from a std::initializer_list.
|
||||||
@@ -258,7 +281,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// Construct an MutableArrayRef from a C array.
|
/// Construct an MutableArrayRef from a C array.
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
/*implicit*/ constexpr MutableArrayRef(T (&Arr)[N])
|
/*implicit*/ LLVM_CONSTEXPR MutableArrayRef(T (&Arr)[N])
|
||||||
: ArrayRef<T>(Arr) {}
|
: ArrayRef<T>(Arr) {}
|
||||||
|
|
||||||
T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
|
T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
|
||||||
@@ -378,4 +401,9 @@ namespace llvm {
|
|||||||
};
|
};
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
|
#ifdef DEFINED_LLVM_CONSTEXPR
|
||||||
|
# undef DEFINED_LLVM_CONSTEXPR
|
||||||
|
# undef LLVM_CONSTEXPR
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user