Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ace / If_Then_Else.h
blob9d645e026e8e8274e38cea6f56f701c02b0b9e03
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file If_Then_Else.h
7 * @c ACE::If_Then_Else traits template based on the @c IfThenElse
8 * template described in the book "C++ Templates" by Vandevoorde and
9 * Josuttis.
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
22 namespace ACE
24 /**
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.
32 * Usage example:
34 * \code
36 * template <typename T>
37 * class Foo
38 * {
39 * public:
40 * // Set "TheType" to be the larger of "T" and "int".
41 * typedef typename If_Then_Else<(sizeof (T) > sizeof (int)),
42 * T,
43 * int>::result_type TheType;
44 * };
46 * \endcode
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>
52 struct If_Then_Else;
54 /**
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;
68 /**
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 */