eval_if.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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