Boost logo

Boost :

Subject: Re: [boost] [contract] concepts: pseudo-signatures vs. usage patterns
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-10-14 03:23:44


2012/10/14 Dave Abrahams <dave_at_[hidden]>

>
> on Sat Oct 13 2012, Andrzej Krzemienski <akrzemi1-AT-gmail.com> wrote:
>
> > I was trying to say that pseudo-signatures look like normal signatures
> > and might imply that no "loose match" occurs. In contrast, usage
> > patterns look like expressions, and you do expect implicit
> > conversions. Although, I do not find it a major argument against
> > pseudo-signatures.
> >
> >> Notationally speaking, I think
> >> pseudo-signatures are *much* more suggestive of those semantics than are
> >> valid expressions.
> >
> > Could you show an example where this is the case?
>
> The example you gave illustrates it, IMO. This is obviously subjective,
> but when you read the requirements as saying "this expression must be
> convertible to bool" there's no obvious reason that when the expression
> appears in a larger context, that conversion necessarily happens.
>
> > I may be missing something obvious, but I would say it is the other
> > way around.
>
> All you have to do is think of the concept and its pseudo-signatures as
> conceptually defining a wrapper interface over the concrete model of the
> concept, through which the constrained function has all interactions
> with the model, and the implicit conversions fall out as a consequence
> of regular language rules. If you follow this mental model for the
> concepts mechanism, many things (some outside the scope of this
> discussion) fall into place logically... or at least they do for me.
>

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?

Regards,
&rzej


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