Boost logo

Boost :

Subject: Re: [boost] [type_traits] Interest in is_iterator type trait?
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2014-08-19 12:53:08


On Aug 19, 2014, at 12:49 PM, John Maddock <boost.regex_at_[hidden]> wrote:

>>> The intent was always to submit is_iterator to Boost, but we never got
>>> around to it. Now I need it in Boost.Filesystem, so I'd rather see it
>>> go in type traits than just sticking it into boost/filesystem/detail.
>>
>> Out of curiosity, why do you need it?
>
> One situation is inside a constructor call:
>
> struct myclass
> {
> template <class I>
> myclass(I a, I b)
> {
> // a and b could be iterators, or could be a pair of values,
> // we need to separate the two cases.
> }

Additionally in this example (a constructor), tag dispatching doesn’t truly work. One has to remove this constructor from the overload resolution set when I is not an iterator (or the right *kind* of iterator), else is_constructible<myclass, I, I> gets the wrong answer.

Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk