q66
19226d51af
This introduces ranged_traits structure, which by default works for things defining .iter(), but also allows you to override it per type at later stage, which comes in handy for std containers. This is because we can't extend the std namespace in any way and we still need to be able to add iterable functionality to std containers even at later stage than iter() is defined.
32 lines
644 B
C++
32 lines
644 B
C++
/* OctaSTD extensions for std::array.
|
|
*
|
|
* This file is part of OctaSTD. See COPYING.md for futher information.
|
|
*/
|
|
|
|
#ifndef OSTD_ARRAY_HH
|
|
#define OSTD_ARRAY_HH
|
|
|
|
#include <array>
|
|
|
|
#include "ostd/range.hh"
|
|
|
|
namespace ostd {
|
|
|
|
template<typename T, size_t N>
|
|
struct ranged_traits<std::array<T, N>> {
|
|
static PointerRange<T> iter(std::array<T, N> &v) {
|
|
return PointerRange<T>{v.data(), N};
|
|
}
|
|
};
|
|
|
|
template<typename T, size_t N>
|
|
struct ranged_traits<std::array<T, N> const> {
|
|
static PointerRange<T const> iter(std::array<T, N> const &v) {
|
|
return PointerRange<T const>{v.data(), N};
|
|
}
|
|
};
|
|
|
|
} /* namespace ostd */
|
|
|
|
#endif
|