aligator 0.17.1
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Loading...
Searching...
No Matches
data.hpp
Go to the documentation of this file.
1/*
2Copyright 2023 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7*/
8#ifndef BOOST_CORE_DATA_HPP
9#define BOOST_CORE_DATA_HPP
10
11#include <iterator>
12
13// Note: MSVC doesn't define __cpp_lib_nonmember_container_access but supports
14// the feature even in C++14 mode
15#if (defined(__cpp_lib_nonmember_container_access) && \
16 (__cpp_lib_nonmember_container_access >= 201411l)) || \
17 (defined(_MSC_VER) && (_MSC_VER >= 1900))
18
19namespace boost {
20using std::data;
21} // namespace boost
22
23#else // (defined(__cpp_lib_nonmember_container_access) ...
24
25#include <cstddef>
26#include <initializer_list>
27
28namespace boost {
29
30template <class C>
31inline constexpr auto data(C &c) noexcept(noexcept(c.data()))
32 -> decltype(c.data()) {
33 return c.data();
34}
35
36template <class C>
37inline constexpr auto data(const C &c) noexcept(noexcept(c.data()))
38 -> decltype(c.data()) {
39 return c.data();
40}
41
42template <class T, std::size_t N> inline constexpr T *data(T (&a)[N]) noexcept {
43 return a;
44}
45
46template <class T>
47inline constexpr const T *data(std::initializer_list<T> l) noexcept {
48 return l.begin();
49}
50
51} // namespace boost
52
53#endif // (defined(__cpp_lib_nonmember_container_access) ...
54
55#endif