is_pixel.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #include <boost/gil/bit_aligned_pixel_reference.hpp>
  9. #include <boost/gil/packed_pixel.hpp>
  10. #include <boost/gil/pixel.hpp>
  11. #include <boost/gil/rgb.hpp>
  12. #include <boost/gil/typedefs.hpp>
  13. #include <boost/gil/concepts/pixel.hpp>
  14. #include <boost/mp11.hpp>
  15. #include "test_fixture.hpp"
  16. namespace gil = boost::gil;
  17. using namespace boost::mp11;
  18. int main()
  19. {
  20. static_assert(std::is_same
  21. <
  22. mp_all_of<gil::test::fixture::pixel_typedefs, gil::is_pixel>,
  23. std::true_type
  24. >::value,
  25. "is_pixel does not yield true for all core pixel types");
  26. static_assert(std::is_same
  27. <
  28. mp_all_of
  29. <
  30. mp_transform
  31. <
  32. gil::test::fixture::nested_pixel_type,
  33. gil::test::fixture::representative_pixel_types
  34. >,
  35. gil::is_pixel
  36. >,
  37. std::true_type
  38. >::value,
  39. "is_pixel does not yield true for representative pixel types");
  40. static_assert(std::is_same
  41. <
  42. mp_all_of<gil::test::fixture::non_pixels, gil::is_pixel>,
  43. std::false_type
  44. >::value,
  45. "is_pixel yields true for non-pixel type");
  46. static_assert(std::is_same
  47. <
  48. mp_none_of<gil::test::fixture::non_pixels, gil::is_pixel>,
  49. std::true_type
  50. >::value,
  51. "is_pixel yields true for non-pixel type");
  52. using bgr121_ref_t = gil::bit_aligned_pixel_reference
  53. <
  54. std::uint8_t, mp_list_c<int, 1, 2, 1>, gil::bgr_layout_t, true
  55. >;
  56. static_assert(gil::is_pixel<bgr121_ref_t>::value,
  57. "is_pixel does not yield true for bit_aligned_pixel_reference");
  58. using rgb121_ref_t = gil::bit_aligned_pixel_reference
  59. <
  60. std::uint8_t, mp_list_c<int, 1, 2, 1>, gil::rgb_layout_t, true
  61. >;
  62. static_assert(gil::is_pixel<bgr121_ref_t>::value,
  63. "is_pixel does not yield true for bit_aligned_pixel_reference");
  64. using rgb121_packed_pixel_t = rgb121_ref_t::value_type;
  65. static_assert(gil::is_pixel<rgb121_packed_pixel_t>::value,
  66. "is_pixel does not yield true for packed_pixel");
  67. }