From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-08-27 12:44:21
----- Original Message -----
From: Dave <dave_at_[hidden]>
Sent: Monday, August 27, 2001 1:54 PM
Subject: Re: [boost] "Strict" type traits
> Fernando Cacciola wrote:
> > > has_trivial_constructor
> . . .
> > > has_no_trivial_constructor
> > >
> > Off the top of my head I would vote for negative traits and double
> > At least, that's what I've been doing and it worked well so far.
> Had negative traits been your natural way of thinking,
> you would have said, "I vote against positive traits" :-)
> Personally, I prefer predicates to be phrased in the
> positive sense whenever possible. For example, I
> prefer the positive assertion:
> My brain has to make one additional logic inversion for:
> I.e., "it is true that the existence of a trivial
> constructor is false." But what really hurts is:
> -- Dave Miller :-)
I think that you misunderstood the proposal.
The idea is the following:
Currently, a call to has_trivial_constructor() (for example) might return
false, not because the input type dosen't has a trivial constructor but
because the predicate is not actually implemented for that type. This is a
problem, since as a user you don't know whether the answer is actually
meaningful or it means 'I don't know'.
One solution is to provide the oposite predicate, which defaults to the same
'don't know value'.
As a user, you won't use the oposite predicate except when you want to
double check the answer of the positive one:
if ( has_trivial_constructor() )
if ( has_not_trivial_constructor() )
// Contradictory, which means that we actually don't know.
BTW: Just as a comment, in my personal design I use the class optional_t<>
(*) to solve this sort of problems:
optional_t<bool> result ;
if ( give_answer )
*result = true/false ;
return result ;
optional_t<bool> pred = predicate();
if ( pred ) // pred defined.
if ( *pred == true )
I can send the optional_t<> class to anyone interested.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk