30 #ifndef BPSTD_ITERATOR_HPP
31 #define BPSTD_ITERATOR_HPP
33 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
37 #include "detail/config.hpp"
42 #include <initializer_list>
44 BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE
53 using reverse_iterator = std::reverse_iterator<T>;
67 template <
typename Iterator>
80 constexpr
auto data(C& c) -> decltype(c.data());
82 constexpr
auto data(
const C& c) -> decltype(c.data());
89 template <
typename T, std::
size_t N>
90 constexpr T*
data(T (&array)[N]) noexcept;
97 constexpr
const E*
data(std::initializer_list<E> il) noexcept;
105 template <
typename C>
106 constexpr
auto empty(
const C& c) -> decltype(c.empty());
112 template <
typename T, std::
size_t N>
113 constexpr
bool empty(
const T (&array)[N]) noexcept;
119 template <
typename E>
120 constexpr
bool empty(std::initializer_list<E> il) noexcept;
128 template <
typename C>
129 constexpr
auto size(
const C& c) -> decltype(c.size());
135 template <
typename T, std::
size_t N>
136 constexpr std::size_t
size(
const T (&array)[N]) noexcept;
144 template <
typename C>
145 constexpr
auto ssize(
const C& c)
146 -> common_type_t<std::ptrdiff_t, make_signed_t<decltype(c.size())>>;
152 template <
typename T, std::ptrdiff_t N>
153 constexpr std::ptrdiff_t
ssize(
const T (&array)[N]) noexcept;
165 template <
typename Iterator>
166 inline BPSTD_INLINE_VISIBILITY constexpr
167 bpstd::reverse_iterator<Iterator>
170 return reverse_iterator<Iterator>{i};
181 template <
typename C>
182 inline BPSTD_INLINE_VISIBILITY constexpr
184 -> decltype(c.data())
189 template <
typename C>
190 inline BPSTD_INLINE_VISIBILITY constexpr
192 -> decltype(c.data())
196 template <
typename T, std::
size_t N>
197 inline BPSTD_INLINE_VISIBILITY constexpr
204 template <
typename E>
205 inline BPSTD_INLINE_VISIBILITY constexpr
214 template <
typename C>
215 inline BPSTD_INLINE_VISIBILITY constexpr
217 -> decltype(c.empty())
222 template <
typename T, std::
size_t N>
223 inline BPSTD_INLINE_VISIBILITY constexpr
230 template <
typename E>
231 inline BPSTD_INLINE_VISIBILITY constexpr
235 return il.begin() == il.end();
240 template <
typename C>
241 inline BPSTD_INLINE_VISIBILITY constexpr
243 -> decltype(c.size())
248 template <
typename T, std::
size_t N>
249 inline BPSTD_INLINE_VISIBILITY constexpr
258 template <
typename C>
259 inline BPSTD_INLINE_VISIBILITY constexpr
261 -> bpstd::common_type_t<std::ptrdiff_t, bpstd::make_signed_t<decltype(c.size())>>
263 using type = bpstd::common_type_t<std::ptrdiff_t, bpstd::make_signed_t<decltype(c.size())>>;
265 return static_cast<type
>(c.size());
268 template <
typename T, std::ptrdiff_t N>
269 inline BPSTD_INLINE_VISIBILITY constexpr
276 BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE