#include <type_traits>
#include <iterator>
#include <vector>
#include <utility>
template <typename T>
struct is_iterator {
static char test(...);
template <typename U,
typename=typename std::iterator_traits<U>::difference_type,
typename=typename std::iterator_traits<U>::pointer,
typename=typename std::iterator_traits<U>::reference,
typename=typename std::iterator_traits<U>::value_type,
typename=typename std::iterator_traits<U>::iterator_category
> static long test(U&&);
static bool value = std::is_same<decltype(test(std::declval<T>())),long>::value;
};
On 2015–06–11, at 4:34 AM, Matthew Fioravante <fmatth...@gmail.com> wrote:Here is one possible implementation:
Just use std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, std::iterator_traits<T>::iterator_category > >.
On 2015–06–11, at 8:30 AM, Matthew Fioravante <fmatth...@gmail.com> wrote:
On Wednesday, June 10, 2015 at 8:23:18 PM UTC-4, David Krauss wrote:Just use std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, std::iterator_traits<T>::iterator_category > >.I still think its better to have a usability wrapper. Your solution works but its less obvious what its doing from a quick glance. A wrapper such as listed below clearly states what condition is being tested and makes the code more readable and obvious.