|
Boost : |
From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-11-20 13:03:43
Andrei Alexandrescu wrote:
> I think if_true in select_type ought to become a first-class
> citizen. It's useful enough to everyone.
>
> I also suggest including the friendlier version:
>
> template <bool flag, typename T, typename U>
> struct select
> {
> typedef T type;
> };
> template <typename T, typename U>
> struct Select<false, T, U>
> {
> typedef U type;
> };
>
> for compilers that support partial specialization. The if_true is
> compiler-friendlier but considerably harder to use (that
> "template" in the middle of it is really annoying).
Please take a look at "boost/mpl/select_type.hpp" header - it already has
'select_type' template that is equivalent to what you propose above, and
also 'select_type_t' variation, which is mainly a workaround for broken
compilers, but, sadly, is useful much more often than one would like it to
be.
-- Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk