libostd/ostd/array.hh
q66 19226d51af since we can't ADL for std container iter, use different system
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.
2017-01-26 00:27:54 +01:00

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