Boost logo

Boost :

Subject: Re: [boost] [Review] Type Traits Extension by Frederic Bron - Review summary and decision
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-04-21 16:01:06

On Thu, Apr 21, 2011 at 12:13 PM, Stewart, Robert <Robert.Stewart_at_[hidden]>wrote:

> Jeffrey Lee Hellrung, Jr. wrote:
> > On Thu, Apr 21, 2011 at 10:29 AM, Stewart, Robert
> > <Robert.Stewart_at_[hidden]>wrote:
> > > Joachim Faulhaber wrote:
> >
> > FWIW, I agree with Joachim on this point. Since they both deal
> > with builtin C++ operators (something in common), *it would be
> > nice* if the part of the name referring to the operator (the
> > common part) were the same (or a slightly varied). The
> > semantic difference between the functor and the trait should,
> > IMO, primarily be conveyed by the prefix or suffix or the
> > particular variation on the "primary" operator name.
> OK. Is "multiplication" a slight enough variation of "multiplies?"



Did you try the thought experiment I suggested in my last post?

To some extent, as I already have a number of these traits lying around.
Looks like, at the time I created these, I preferred the "is_xxxable" form
for those traits (is_left_shiftable, is_pre_incrementable, etc.). I guess I
was naming the trait after the operation rather than the operator. I think
some for some operators, though, that formula is a bit awkward, e.g., with
"+=". I would think to call that "has_plus_equal" or
"has_operator_plus_equal" or "can_call_plus_equal" depending on what the
understood prefix was. It seems we're going with the "name after the
operator" route, here, which I have no problem with; it's easier to apply
that formula universally to all operators, I think, and that's probably what
Frederic discovered as well. Then a question is what to call each
operator. I wouldn't initially think to call "+=" the "addition assignment"
operator, but that's just me.

> Also, while we're on the topic of what *I* prefer: I still
> > prefer "has_xxx". To me, it has an implicit association (to
> > me, anyway) to the names of trait predicates; it has simplicity
> > and brevity; and it has existing use in Boost.TypeTraits.
> What about all of the "is_" prefixed traits

Those, too!

> and other names in Boost.TypeTraits with prefixes like "add_" and
> "remove_,"

Those aren't predicates...

> and those without a prefix?

Such as...?

> There's clear precedent for different prefixes for different purposes
> within the library. Remember that "has_" implies ownership or inherent
> characteristic which doesn't apply to a namespace scope operator.

Well, I don't think it's confusing to say that "A has a plus operator" is
equivalent to "A + A is well-formed". Like I said, I understand that
arguments against "has_xxx", but it's still more natural to me than

- Jeff

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