From: Alex Chovanec (achovane_at_[hidden])
Date: 2004-08-22 20:35:04
"Jonathan Turkanis" <technews_at_[hidden]> wrote in message
> "Alex Chovanec" <achovane_at_[hidden]> wrote in message
> I've attached a naively modified version of David Abraham's
> is_incrementable as a first attempt at is_dereferenceable. There may
> be all sorts of subtle issues I haven't though of.
Ok I'll check it out. Maybe it's more robust than the SFINAE approach to
recognizing overloaded operators which I'm using right now.
> > (and
> > more generally, whether or not it's an iterator).
> Why? When you write a template, you always have some idea of the range
> of types for which the template should be instantiated. It's rarely
> instantiable for all types. Given this, all you need is a way to
> separate iterators from the other candidate template arguments.
Ok, so I have a class Ptr_Wrapper that is a wrapper around a pointer to an
object of arbitrary type, and it has a template constructor which accepts
any kind of iterator. The constructor initializes the pointer member with
the address of the object that the iterator refers to.
Now, I don't want is_convertible<T, Ptr_Wrapper> to be true for any type T,
so I want to use the enable_if library to eliminate specializations of the
template constructor where the type passed in is not a Readable Lvalue
iterator with the correct pointer type. But again, I can't just use
is_readable_iterator<T> and is_lvalue_iterator<T>, because either one will
cause a compile error if T is not an iterator.
I don't want there to be a compile error in this case, because Ptr_Wrapper
has another constructor which accepts a reference to an object an
initializes the pointer member from that. I want this constructor to be
chosen if a reference is passed instead of an iterator.
Thus, in the template metaprogram that I use to decide whether or not to
include a particular template specialization of the constructor in the set
of candidate functions, I need to check that T is some kind of iterator
before applying is_readable_iterator<T> and is_lvalue_iterator<T>.
Otherwise, I may get an unwanted compile error.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk