File indexing completed on 2025-01-18 09:38:12
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_HISTOGRAM_DETAIL_NONMEMBER_CONTAINER_ACCESS_HPP
0008 #define BOOST_HISTOGRAM_DETAIL_NONMEMBER_CONTAINER_ACCESS_HPP
0009
0010 #include <initializer_list>
0011 #include <type_traits>
0012 #include <valarray>
0013
0014 namespace boost {
0015 namespace histogram {
0016 namespace detail {
0017
0018 template <class C>
0019 constexpr auto data(C& c) -> decltype(c.data()) {
0020 return c.data();
0021 }
0022
0023 template <class C>
0024 constexpr auto data(const C& c) -> decltype(c.data()) {
0025 return c.data();
0026 }
0027
0028 template <class T, std::size_t N>
0029 constexpr T* data(T (&array)[N]) noexcept {
0030 return array;
0031 }
0032
0033 template <class E>
0034 constexpr const E* data(std::initializer_list<E> il) noexcept {
0035 return il.begin();
0036 }
0037
0038 template <class E>
0039 constexpr const E* data(const std::valarray<E>& v) noexcept {
0040 return std::begin(v);
0041 }
0042
0043 template <class E>
0044 constexpr E* data(std::valarray<E>& v) noexcept {
0045 return std::begin(v);
0046 }
0047
0048 template <class C>
0049 constexpr auto size(const C& c) -> decltype(c.size()) {
0050 return c.size();
0051 }
0052
0053 template <class T, std::size_t N>
0054 constexpr std::size_t size(const T (&)[N]) noexcept {
0055 return N;
0056 }
0057
0058 }
0059 }
0060 }
0061
0062 #endif