Boost logo

Boost :

Subject: Re: [boost] [contract] concepts: pseudo-signatures vs. usage patterns
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-10-14 14:59:26

on Sun Oct 14 2012, "Jeffrey Lee Hellrung, Jr." <> wrote:

> On Sun, Oct 14, 2012 at 12:23 AM, Andrzej Krzemienski <akrzemi1_at_[hidden]>wrote:
> [...]
>> Can you help me understand one thing about pseudo-signatures? If I have the
>> following concept:
>> concept MyIter<typename It>
>> {
>> It& operator++(It&);
>> bool It::is_valid();
>> }
>> Does this say preincrement returns exactly reference to It or only
>> something convertible to It? If it is the latter, it would mean that the
>> concept model where pre-increment only returns something convertible to It&
>> satisfies the concept, but makes the following usage invalid:
>> template <MyIter It>
>> void test_next(It i)
>> {
>> return (++it).is_valid();
>> }
>> Or am I wrong?
> My understanding, based only on reading this thread, is that, since It is
> declared as a model of MyIter (I'm not sure what the correct terminology is
> to express the relationship between It and MyIter within the scope of a
> "template <MyIter It>" declaration, but that's what I mean by "is declared
> as a model of"), ++it in the above context refers to the
> (pseudo-?)signature declared in the MyIter concept definition (hence has
> return type It&).


> The operator++ within the MyIter concept definition implicitly (by
> default?) uses the operator++ of It, plus it adds a (implicit)
> conversion of the result to an It&, if necessary.

Precisely again.

> So I would think the body of test_next would be entirely valid (no pun
> intended)...modulo the attempted bool -> void conversion :)


> Aside: This discussion, of which I've only been a casual observer, has
> definitely been interesting.

Glad to help.

Dave Abrahams
BoostPro Computing                  Software Development        Training             Clang/LLVM/EDG Compilers  C++  Boost

Boost list run by bdawes at, gregod at, cpdaniel at, john at