better support for plain pointer iterators in containers.hh

use std::iterator_traits<T>::value_type instead of T::value_type
that will fail when T is not of class type.
This commit is contained in:
Maxime Coste 2017-01-02 05:13:58 +00:00
parent 4901a02e50
commit 20c47b8d61

View File

@ -61,7 +61,7 @@ struct FilterView
using ContainerIt = IteratorOf<Container>;
struct Iterator : std::iterator<std::forward_iterator_tag,
typename ContainerIt::value_type>
typename std::iterator_traits<ContainerIt>::value_type>
{
Iterator(const FilterView& view, ContainerIt it, ContainerIt end)
: m_it{std::move(it)}, m_end{std::move(end)}, m_view{view}
@ -254,12 +254,13 @@ struct ConcatView
{
using ContainerIt1 = decltype(begin(std::declval<Container1>()));
using ContainerIt2 = decltype(begin(std::declval<Container2>()));
using ValueType = typename std::common_type<typename ContainerIt1::value_type, typename ContainerIt2::value_type>::type;
using ValueType = typename std::common_type<typename std::iterator_traits<ContainerIt1>::value_type,
typename std::iterator_traits<ContainerIt2>::value_type>::type;
struct Iterator : std::iterator<std::forward_iterator_tag, ValueType>
{
static_assert(std::is_convertible<typename ContainerIt1::value_type, ValueType>::value, "");
static_assert(std::is_convertible<typename ContainerIt2::value_type, ValueType>::value, "");
static_assert(std::is_convertible<typename std::iterator_traits<ContainerIt1>::value_type, ValueType>::value, "");
static_assert(std::is_convertible<typename std::iterator_traits<ContainerIt2>::value_type, ValueType>::value, "");
Iterator(ContainerIt1 it1, ContainerIt1 end1, ContainerIt2 it2)
: m_it1(std::move(it1)), m_end1(std::move(end1)),