3 //=============================================================================
7 * @c ACE::If_Then_Else traits template based on the @c IfThenElse
8 * template described in the book "C++ Templates" by Vandevoorde and
11 * @author Ossama Othman <ossama@dre.vanderbilt.edu>
13 //=============================================================================
15 #ifndef ACE_IF_THEN_ELSE_H
16 #define ACE_IF_THEN_ELSE_H
18 #include /**/ "ace/config-lite.h"
20 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 * @struct If_Then_Else
27 * @brief Compile-time selection of type based on a boolean value.
29 * This primary template selects the second or third argument based
30 * on the value of the boolean first argument.
36 * template <typename T>
40 * // Set "TheType" to be the larger of "T" and "int".
41 * typedef typename If_Then_Else<(sizeof (T) > sizeof (int)),
43 * int>::result_type TheType;
48 * @note This merely a forward declaration since we really only care
49 * about the partial specializations below.
51 template <bool C
, typename Ta
, typename Tb
>
55 * @struct If_Then_Else
57 * @brief Select of type @a Ta if boolean value is @c true.
59 * This partial specialization selects the type @a Ta if the boolean
60 * first argument is @c true.
62 template <typename Ta
, typename Tb
>
63 struct If_Then_Else
<true, Ta
, Tb
>
65 typedef Ta result_type
;
69 * @struct If_Then_Else
71 * @brief Select of type @a Tb if boolean value is @c false.
73 * This partial specialization selects the type @a Tb if the boolean
74 * first argument is @c false.
76 template <typename Ta
, typename Tb
>
77 struct If_Then_Else
<false, Ta
, Tb
>
79 typedef Tb result_type
;
83 ACE_END_VERSIONED_NAMESPACE_DECL
85 #endif /* ACE_IF_THEN_ELSE_H */