is_even.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef BOOST_MPL_MATH_IS_EVEN_HPP_INCLUDED
  2. #define BOOST_MPL_MATH_IS_EVEN_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/bool.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/workaround.hpp>
  18. namespace boost { namespace mpl {
  19. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
  20. namespace aux
  21. {
  22. template <class N>
  23. struct is_even_base
  24. {
  25. enum { value = (N::value % 2) == 0 };
  26. typedef bool_<value> type;
  27. };
  28. }
  29. #endif
  30. template<
  31. typename BOOST_MPL_AUX_NA_PARAM(N)
  32. >
  33. struct is_even
  34. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
  35. : aux::is_even_base<N>::type
  36. #else
  37. : bool_<((N::value % 2) == 0)>
  38. #endif
  39. {
  40. BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_even,(N))
  41. };
  42. BOOST_MPL_AUX_NA_SPEC(1, is_even)
  43. }}
  44. #endif // BOOST_MPL_MATH_IS_EVEN_HPP_INCLUDED