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:
Danny Robson 2016-06-28 14:06:02 +10:00
parent 1717458c7a
commit 722dbbe18f
2 changed files with 6 additions and 6 deletions

View File

@ -61,11 +61,11 @@ namespace util {
};
template <typename T>
view<typename T::iterator>
auto
make_view (T&);
template <typename T>
view<typename T::const_iterator>
auto
make_view (const T&);
template <typename T>

View File

@ -152,17 +152,17 @@ util::view<T>::operator== (const view<T> rhs) const noexcept
///////////////////////////////////////////////////////////////////////////////
template <typename T>
util::view<typename T::iterator>
auto
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>
util::view<typename T::const_iterator>
auto
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 () };
}