Boost logo

Boost :

Subject: Re: [boost] [typeof] Determining if a type has been registered or not at compile time
From: Peder Holt (peder.holt_at_[hidden])
Date: 2009-12-27 15:41:15

> One way to workaroun this is to allow the user to add a default type:
>> typedef
>> BOOST_TYPEOF_WITH_DEFAULT(some_expression,some_backup_type_if_some_expression_not_registered)
>> type;
>> Is this acceptable?
> Yes, that seems the best solution. An excellent idea. Should I create a
> Trac suggestion for it or will you remember to implement it if you decide to
> do it ? If you do this, I think you will want to do it for TYPEOF_TPL also.
> I see much less use for AUTO and AUTO_TPL defaults if the type is not
> registered but I think you should also implement it for these two also both
> to be orthogonal and for the possibility that someone will find a use there
> also.
I will remember :)
I am, however, not sure about the proper name for this beast. Also, I am a
bit uncertain about the best behaviour:

I see mainly two options:
typedef BOOST_TYPEOF_WITH_DEFAULT(expression,typename
some_alternative_expression::type) type;

typedef BOOST_TYPEOF_WITH_DEFAULT(expression,no_type) deduced_type;
typedef mpl::eval_if<
>::type type;

In the second alternative we could simplify the name to
BOOST_SAFE_TYPEOF(expression) or
BOOST_TYPEOF_OR_NONE(expression) or

And, yes, I agree that this should be implemented for TPL. Only the first
alternative can be implemented with AUTO...

Another alternative is to implement alternative 1 an then alternative 2 by
using alternative 1. I am still unsure about the name.
BOOST_TYPEOF_WITH_DEFAULT seems a very long name, and not overly descriptive


> _______________________________________________
> Unsubscribe & other changes:

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