eval_if.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef BOOST_MPL_EVAL_IF_HPP_INCLUDED
  2. #define BOOST_MPL_EVAL_IF_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/if.hpp>
  14. #include <boost/mpl/aux_/na_spec.hpp>
  15. #include <boost/mpl/aux_/lambda_support.hpp>
  16. #include <boost/mpl/aux_/config/msvc.hpp>
  17. #include <boost/mpl/aux_/config/gcc.hpp>
  18. #include <boost/mpl/aux_/config/workaround.hpp>
  19. namespace boost { namespace mpl {
  20. template<
  21. typename BOOST_MPL_AUX_NA_PARAM(C)
  22. , typename BOOST_MPL_AUX_NA_PARAM(F1)
  23. , typename BOOST_MPL_AUX_NA_PARAM(F2)
  24. >
  25. struct eval_if
  26. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
  27. || ( BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, >= 0x0300) \
  28. && BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, BOOST_TESTED_AT(0x0304)) \
  29. )
  30. {
  31. typedef typename if_<C,F1,F2>::type f_;
  32. typedef typename f_::type type;
  33. #else
  34. : if_<C,F1,F2>::type
  35. {
  36. #endif
  37. BOOST_MPL_AUX_LAMBDA_SUPPORT(3,eval_if,(C,F1,F2))
  38. };
  39. // (almost) copy & paste in order to save one more
  40. // recursively nested template instantiation to user
  41. template<
  42. bool C
  43. , typename F1
  44. , typename F2
  45. >
  46. struct eval_if_c
  47. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
  48. || ( BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, >= 0x0300) \
  49. && BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, BOOST_TESTED_AT(0x0304)) \
  50. )
  51. {
  52. typedef typename if_c<C,F1,F2>::type f_;
  53. typedef typename f_::type type;
  54. #else
  55. : if_c<C,F1,F2>::type
  56. {
  57. #endif
  58. };
  59. BOOST_MPL_AUX_NA_SPEC(3, eval_if)
  60. }}
  61. #endif // BOOST_MPL_EVAL_IF_HPP_INCLUDED