view: move array constructor to make_array function

This commit is contained in:
Danny Robson 2016-11-14 21:29:16 +11:00
parent 86d35bf903
commit 86332b4d3c
2 changed files with 13 additions and 14 deletions

View File

@ -29,10 +29,6 @@ namespace util {
public:
using value_type = typename std::iterator_traits<remove_restrict_t<T>>::value_type;
template <size_t S>
constexpr explicit
view (const value_type (&arr)[S]) noexcept;
constexpr
view (T first, T last) noexcept;
@ -63,6 +59,10 @@ namespace util {
T m_end;
};
template <typename T, size_t N>
auto
make_view (const T (&)[N]);
template <typename T>
auto
make_view (T&);

View File

@ -27,16 +27,6 @@
///////////////////////////////////////////////////////////////////////////////
template <typename T>
template <size_t S>
constexpr
util::view<T>::view (const value_type(&arr)[S]) noexcept:
m_begin (arr),
m_end (arr + S)
{ ; }
//-----------------------------------------------------------------------------
template <typename T>
constexpr
util::view<T>::view (T _begin, T _end) noexcept:
m_begin (_begin),
@ -171,6 +161,15 @@ util::view<T>::operator== (const view<T> rhs) const noexcept
///////////////////////////////////////////////////////////////////////////////
template <typename T, size_t N>
auto
util::make_view (const T (&arr)[N])
{
return util::view<T*> { arr, arr + N };
}
//-----------------------------------------------------------------------------
template <typename T>
auto
util::make_view (T &t)