view: use decltype for make_view type deduction
some types will not have iterator typedefs but are capable of providing iterators. use the types that std::begin and friends return instead of deducing them ourselves.
This commit is contained in:
parent
1717458c7a
commit
722dbbe18f
4
view.hpp
4
view.hpp
@ -61,11 +61,11 @@ namespace util {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
view<typename T::iterator>
|
auto
|
||||||
make_view (T&);
|
make_view (T&);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
view<typename T::const_iterator>
|
auto
|
||||||
make_view (const T&);
|
make_view (const T&);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
8
view.ipp
8
view.ipp
@ -152,17 +152,17 @@ util::view<T>::operator== (const view<T> rhs) const noexcept
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
util::view<typename T::iterator>
|
auto
|
||||||
util::make_view (T &t)
|
util::make_view (T &t)
|
||||||
{
|
{
|
||||||
return util::view<typename T::iterator> { t.begin (), t.end () };
|
return util::view<decltype(std::begin (t))> { t.begin (), t.end () };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
util::view<typename T::const_iterator>
|
auto
|
||||||
util::make_view (const T &t)
|
util::make_view (const T &t)
|
||||||
{
|
{
|
||||||
return util::view<typename T::const_iterator> { t.cbegin (), t.cend () };
|
return util::view<decltype(std::cbegin (t))> { t.cbegin (), t.cend () };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user