Boost logo

Boost Users :

Subject: Re: [Boost-users] A forward iterator need not be default-constructible
From: Krzysztof Żelechowski (giecrilj_at_[hidden])
Date: 2011-09-30 06:04:41

Andrew Sutton wrote:

> template<typename I>
> auto f() { I i; assert(*i); } // worst algorithm ever
> If I know that the iterator has valid operations after being default
> constructed, then I'll do as I like -- whatever the concept does or
> does not say.

OTOH, if I know that a singular iterator of some type would have no valid
operations, and the iterator is only meant to be used by algorithms, the
benefit of being unable to create a singular iterator (like when the
iterator in question holds a reference to supporting data used in its
operation) outweighs the benefit of being able to do so.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at