1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/pending/ct_if.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,111 @@
1.4 +// (C) Copyright Jeremy Siek 2000.
1.5 +// Distributed under the Boost Software License, Version 1.0. (See
1.6 +// accompanying file LICENSE_1_0.txt or copy at
1.7 +// http://www.boost.org/LICENSE_1_0.txt)
1.8 +
1.9 +// The ct_if implementation that avoids partial specialization is
1.10 +// based on the IF class by Ulrich W. Eisenecker and Krzysztof
1.11 +// Czarnecki.
1.12 +
1.13 +#ifndef BOOST_CT_IF_HPP
1.14 +#define BOOST_CT_IF_HPP
1.15 +
1.16 +#include <boost/config.hpp>
1.17 +
1.18 +/*
1.19 + There is a bug in the Borland compiler with regards to using
1.20 + integers to specialize templates. This made it hard to use ct_if in
1.21 + the graph library. Changing from 'ct_if' to 'ct_if_t' fixed the
1.22 + problem.
1.23 +*/
1.24 +
1.25 +#include <boost/type_traits/integral_constant.hpp> // true_type and false_type
1.26 +
1.27 +namespace boost {
1.28 +
1.29 + struct ct_if_error { };
1.30 +
1.31 + template <class A, class B>
1.32 + struct ct_and { typedef false_type type; };
1.33 + template <> struct ct_and<true_type,true_type> { typedef true_type type; };
1.34 +
1.35 + template <class A> struct ct_not { typedef ct_if_error type; };
1.36 + template <> struct ct_not<true_type> { typedef false_type type; };
1.37 + template <> struct ct_not<false_type> { typedef true_type type; };
1.38 +
1.39 +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.40 +
1.41 +// agurt, 15/sep/02: in certain cases Borland has problems with
1.42 +// choosing the right 'ct_if' specialization even though 'cond'
1.43 +// _does_ equal '1'; the easiest way to fix it is to make first
1.44 +// 'ct_if' non-type template parameter boolean.
1.45 +#if !defined(__BORLANDC__)
1.46 + template <bool cond, class A, class B>
1.47 + struct ct_if { typedef ct_if_error type; };
1.48 + template <class A, class B>
1.49 + struct ct_if<true, A, B> { typedef A type; };
1.50 + template <class A, class B>
1.51 + struct ct_if<false, A, B> { typedef B type; };
1.52 +#else
1.53 + template <bool cond, class A, class B>
1.54 + struct ct_if { typedef A type; };
1.55 + template <class A, class B>
1.56 + struct ct_if<false, A, B> { typedef B type; };
1.57 +#endif
1.58 +
1.59 + template <class cond, class A, class B>
1.60 + struct ct_if_t { typedef ct_if_error type; };
1.61 + template <class A, class B>
1.62 + struct ct_if_t<true_type, A, B> { typedef A type; };
1.63 + template <class A, class B>
1.64 + struct ct_if_t<false_type, A, B> { typedef B type; };
1.65 +
1.66 +#else
1.67 +
1.68 + namespace detail {
1.69 +
1.70 + template <int condition, class A, class B> struct IF;
1.71 + template <int condition> struct SlectSelector;
1.72 + struct SelectFirstType;
1.73 + struct SelectSecondType;
1.74 +
1.75 + struct SelectFirstType {
1.76 + template<class A, class B>
1.77 + struct Template { typedef A type; };
1.78 + };
1.79 +
1.80 + struct SelectSecondType {
1.81 + template<class A, class B>
1.82 + struct Template { typedef B type; };
1.83 + };
1.84 +
1.85 + template<int condition>
1.86 + struct SlectSelector {
1.87 + typedef SelectFirstType type;
1.88 + };
1.89 +
1.90 + template <>
1.91 + struct SlectSelector<0> {
1.92 + typedef SelectSecondType type;
1.93 + };
1.94 +
1.95 + } // namespace detail
1.96 +
1.97 + template<int condition, class A, class B>
1.98 + struct ct_if
1.99 + {
1.100 + typedef typename detail::SlectSelector<condition>::type Selector;
1.101 + typedef typename Selector::template Template<A, B>::type type;
1.102 + };
1.103 +
1.104 + template <class cond, class A, class B>
1.105 + struct ct_if_t {
1.106 + typedef typename ct_if<cond::value, A, B>::type type;
1.107 + };
1.108 +
1.109 +#endif
1.110 +
1.111 +} // namespace boost
1.112 +
1.113 +#endif // BOOST_CT_IF_HPP
1.114 +