arithmetic.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright Aleksey Gurtovoy 2001-2004
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/mpl for documentation.
  8. // $Id$
  9. // $Date$
  10. // $Revision$
  11. #include <boost/mpl/arithmetic.hpp>
  12. #include <boost/mpl/int.hpp>
  13. #include <boost/mpl/aux_/test.hpp>
  14. MPL_TEST_CASE()
  15. {
  16. typedef int_<0> _0;
  17. typedef int_<1> _1;
  18. typedef int_<3> _3;
  19. typedef int_<10> _10;
  20. MPL_ASSERT_RELATION( (plus<_0,_10>::value), ==, 10 );
  21. MPL_ASSERT_RELATION( (plus<_10,_0>::value), ==, 10 );
  22. MPL_ASSERT_RELATION( (minus<_0,_10>::value), ==, -10 );
  23. MPL_ASSERT_RELATION( (minus<_10,_0>::value), ==, 10 );
  24. MPL_ASSERT_RELATION( (times<_1,_10>::value), ==, 10 );
  25. MPL_ASSERT_RELATION( (times<_10,_1>::value), ==, 10 );
  26. MPL_ASSERT_RELATION( (multiplies<_1,_10>::value), ==, 10 );
  27. MPL_ASSERT_RELATION( (multiplies<_10,_1>::value), ==, 10 );
  28. MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
  29. MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
  30. MPL_ASSERT_RELATION( (modulus<_10,_1>::value), ==, 0 );
  31. MPL_ASSERT_RELATION( (modulus<_10,_3>::value), ==, 1 );
  32. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  33. MPL_ASSERT_RELATION( (minus<_10,_1,_10>::value), ==, -1 );
  34. MPL_ASSERT_RELATION( (plus<_10,_1,_10>::value), ==, 21 );
  35. MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
  36. MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
  37. #endif
  38. MPL_ASSERT_RELATION( negate<_10>::value, ==, -10 );
  39. }