|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-11-27 13:01:33
----- Original Message -----
From: Peter Dimov <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, November 27, 2001 8:30 AM
Subject: Re: [boost] Submission: typelist
>
> Finally, I like the int2type<> and type2type<> names. They are
sufficiently
> obvious to me. I don't see a need to change them into *_identity.
>
I've tried to follow this discussion but it is going too fast for my little
time.
But, at the risk of being totally off the track, I have a comment about
int2type<> and int<>.
Notice, however, that I couldn't really follow the discussion, so this might
be totally useless
and in that case just disregard it completely.
In my code for numeric_conversions_traits<>
(which I expect to submit for formal review before the end of this week),
I've come to the following:
On one hand, I have:
struct false_t { BOOST_STATIC_CONSTANT(bool, value = false ) ; } ;
struct true_t { BOOST_STATIC_CONSTANT(bool, value = true ) ; } ;
And then:
template<bool expr> struct bool2type { typedef true_t type ; } ;
template<> struct bool2type<false> { typedef false_t type ; } ;
Now, I can't use "bool2type<B>" itself because it is not a unique type, so,
in order
to use it in a "select_t" I MUST use it as in:
select_t< typename bool2type<B>::type >
that is, with the extra "::type".
on the other hand, I also need to convert an 'int' into a type,
so I could have used:
template<int N> struct int2type { BOOST_STATIC_CONSTANT(int, value = N ) ; }
;
However, in this case I would use it as in:
add_t< int2type<2>, int2type<3> >::type ;
that is, without "::type"; but I found that it is inconsistent w.r.t to the
bool2type<> case.
therefore, I ended up using:
template<int N> struct int_t { BOOST_STATIC_CONSTANT(int, value = N ) ; } ;
template<int N> struct int2type { typedef int_t<N> type ; } ;
which is used as in:
add_t< int2type<2>::type, int2type<3>::type >::type ;
Is this any useful to the discussion?
Just my 2 cents.
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk