1 | /* |
2 | Copyright 2019 Glen Joseph Fernandes |
3 | (glenjofe@gmail.com) |
4 | |
5 | Distributed under the Boost Software License, Version 1.0. |
6 | (http://www.boost.org/LICENSE_1_0.txt) |
7 | */ |
8 | #ifndef BOOST_CORE_FIRST_SCALAR_HPP |
9 | #define BOOST_CORE_FIRST_SCALAR_HPP |
10 | |
11 | #include <boost/config.hpp> |
12 | #include <cstddef> |
13 | |
14 | namespace boost { |
15 | namespace detail { |
16 | |
17 | template<class T> |
18 | struct make_scalar { |
19 | typedef T type; |
20 | }; |
21 | |
22 | template<class T, std::size_t N> |
23 | struct make_scalar<T[N]> { |
24 | typedef typename make_scalar<T>::type type; |
25 | }; |
26 | |
27 | } /* detail */ |
28 | |
29 | template<class T> |
30 | BOOST_CONSTEXPR inline T* |
31 | first_scalar(T* p) BOOST_NOEXCEPT |
32 | { |
33 | return p; |
34 | } |
35 | |
36 | template<class T, std::size_t N> |
37 | BOOST_CONSTEXPR inline typename detail::make_scalar<T>::type* |
38 | first_scalar(T (*p)[N]) BOOST_NOEXCEPT |
39 | { |
40 | return boost::first_scalar(&(*p)[0]); |
41 | } |
42 | |
43 | } /* boost */ |
44 | |
45 | #endif |
46 | |