From 63e2a1a98a96d9aa725ca32dac0033d3ccb6caa7 Mon Sep 17 00:00:00 2001 From: Mateusz Loskot Date: Fri, 7 Dec 2018 23:55:13 +0100 Subject: [PATCH] Fix compile-time bugs subchroma_image.hpp definions (#164) Add missing typename in mpl::if_ condition result. Restore BOOST_CXX14_CONSTEXPR in boost::algorithm::clamp function - apparently, GCC 5.5.0 does not compile it with C++11 constexpr. Still not adding subchroma_image.cpp to toolbox test target input sources due to run-time failure. Depends on #176 --- .../boost/gil/extension/toolbox/color_spaces/ycbcr.hpp | 3 ++- .../extension/toolbox/image_types/subchroma_image.hpp | 9 ++++----- toolbox/test/CMakeLists.txt | 3 +++ toolbox/test/Jamfile | 3 +++ toolbox/test/fabscript | 2 ++ toolbox/test/subchroma_image.cpp | 4 ++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/boost/gil/extension/toolbox/color_spaces/ycbcr.hpp b/include/boost/gil/extension/toolbox/color_spaces/ycbcr.hpp index d933ce90a..d6baa39f9 100644 --- a/include/boost/gil/extension/toolbox/color_spaces/ycbcr.hpp +++ b/include/boost/gil/extension/toolbox/color_spaces/ycbcr.hpp @@ -13,6 +13,7 @@ #include #include // FIXME: Include what you use! +#include #include #include #include @@ -60,7 +61,7 @@ namespace detail { // Source:boost/algorithm/clamp.hpp template -constexpr T const& clamp(T const& val, +BOOST_CXX14_CONSTEXPR T const& clamp(T const& val, typename boost::mpl::identity::type const & lo, typename boost::mpl::identity::type const & hi) { diff --git a/include/boost/gil/extension/toolbox/image_types/subchroma_image.hpp b/include/boost/gil/extension/toolbox/image_types/subchroma_image.hpp index 9883288f0..f9dd9039b 100644 --- a/include/boost/gil/extension/toolbox/image_types/subchroma_image.hpp +++ b/include/boost/gil/extension/toolbox/image_types/subchroma_image.hpp @@ -54,14 +54,13 @@ struct scaling_factors >::type::value ) ); - BOOST_STATIC_CONSTANT( int, ss_Y = ( mpl::if_< mpl::equal_to< mpl::int_, mpl::int_< 0 > > + BOOST_STATIC_CONSTANT( int, ss_Y = (mpl::if_< mpl::equal_to< mpl::int_, mpl::int_< 0 > > , mpl::int_< 2 > - , mpl::if_< mpl::equal_to< mpl::int_, mpl::int_ > + , typename mpl::if_< mpl::equal_to< mpl::int_, mpl::int_ > , mpl::int_< 1 > , mpl::int_< 4 > - > - >::type::value ) - ); + >::type + >::type::value)); }; } // namespace detail diff --git a/toolbox/test/CMakeLists.txt b/toolbox/test/CMakeLists.txt index 67e4e5db5..b66a3a27e 100644 --- a/toolbox/test/CMakeLists.txt +++ b/toolbox/test/CMakeLists.txt @@ -32,6 +32,9 @@ target_sources(gil_test_ext_toolbox lab_test.cpp pixel_bit_size.cpp rgb_to_luminance.cpp + # TODO: Add subchroma_image.cpp after fixing run-time failure, + # for details see https://github.com/boostorg/gil/pull/164 + #subchroma_image.cpp xyz_test.cpp) target_link_libraries(gil_test_ext_toolbox PRIVATE diff --git a/toolbox/test/Jamfile b/toolbox/test/Jamfile index 0cb62be3c..8d14cb588 100644 --- a/toolbox/test/Jamfile +++ b/toolbox/test/Jamfile @@ -31,5 +31,8 @@ run lab_test.cpp pixel_bit_size.cpp rgb_to_luminance.cpp + # TODO: Add subchroma_image.cpp after fixing run-time failure, + # for details see https://github.com/boostorg/gil/pull/164 + #subchroma_image.cpp xyz_test.cpp ; diff --git a/toolbox/test/fabscript b/toolbox/test/fabscript index 3a28db3d0..6f52f82e2 100644 --- a/toolbox/test/fabscript +++ b/toolbox/test/fabscript @@ -30,6 +30,8 @@ def gil_test(name, sources, features, condition=True): return test(name, binary(name, sources, features=features, condition=condition)) +# TODO: Add `subchroma_image.cpp` after fixing run-time failure, +# for details see https://github.com/boostorg/gil/pull/164 tests = [gil_test('toolbox', ['test.cpp', 'channel_type.cpp', 'channel_view.cpp', 'cmyka.cpp', 'get_num_bits.cpp', 'get_pixel_type.cpp', 'gray_alpha.cpp', 'gray_to_rgba.cpp', diff --git a/toolbox/test/subchroma_image.cpp b/toolbox/test/subchroma_image.cpp index b96523d93..e4536d28f 100644 --- a/toolbox/test/subchroma_image.cpp +++ b/toolbox/test/subchroma_image.cpp @@ -8,7 +8,6 @@ #include #include - #include #include @@ -92,7 +91,8 @@ BOOST_AUTO_TEST_CASE( subchroma_image_test ) , y_height , &data.front() ); - rgb8_pixel_t p = *v.xy_at( 0, 0 ); + rgb8_pixel_t p; + p = *v.xy_at( 0, 0 ); } }