promote_mpl_test.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2005 Alexander Nasonov.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/mpl/at.hpp>
  6. #include <boost/mpl/lambda.hpp>
  7. #include <boost/mpl/placeholders.hpp>
  8. #include <boost/mpl/transform.hpp>
  9. #include <boost/mpl/vector.hpp>
  10. #include <boost/static_assert.hpp>
  11. #include <boost/type_traits/is_same.hpp>
  12. #include <boost/type_traits/promote.hpp>
  13. namespace mpl = boost::mpl;
  14. int main()
  15. {
  16. using namespace mpl::placeholders;
  17. typedef mpl::vector< char
  18. , signed char // 1
  19. , unsigned char
  20. , short int const // 3
  21. , unsigned short int
  22. , int volatile // 5
  23. , unsigned int // 6
  24. , long // 7
  25. , unsigned long // 8
  26. , float const // 9
  27. > types;
  28. typedef mpl::transform< types
  29. , mpl::lambda< boost::promote<_> >::type
  30. >::type promoted;
  31. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,1>::type, int >::value ));
  32. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,3>::type, int const >::value ));
  33. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,5>::type, int volatile >::value ));
  34. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,6>::type, unsigned int >::value ));
  35. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,7>::type, long >::value ));
  36. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,8>::type, unsigned long >::value ));
  37. BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,9>::type, double const >::value ));
  38. return 0;
  39. }