diff --git a/doc/design_guide.rst b/doc/design_guide.rst index 79b267dab..556865a72 100644 --- a/doc/design_guide.rst +++ b/doc/design_guide.rst @@ -2794,7 +2794,7 @@ called when we dereference a pixel iterator. It will call typedef const value_type& const_reference; typedef SrcConstRefP argument_type; typedef reference result_type; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; result_type operator()(argument_type srcP) const { result_type dstP; diff --git a/doc/doxygen/design_guide.dox b/doc/doxygen/design_guide.dox index 6eda18d8f..3499e181a 100644 --- a/doc/doxygen/design_guide.dox +++ b/doc/doxygen/design_guide.dox @@ -2720,7 +2720,7 @@ public: typedef const value_type& const_reference; typedef SrcConstRefP argument_type; typedef reference result_type; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; result_type operator()(argument_type srcP) const { result_type dstP; diff --git a/doc/doxygen/tutorial.dox b/doc/doxygen/tutorial.dox index 49cd94f3b..dc1150e88 100644 --- a/doc/doxygen/tutorial.dox +++ b/doc/doxygen/tutorial.dox @@ -587,7 +587,7 @@ struct mandelbrot_fn { typedef value_type const_reference; typedef point_t argument_type; typedef reference result_type; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; mandelbrot_fn() {} mandelbrot_fn(const point_t& sz) : _img_size(sz) {} diff --git a/doc/tutorial.rst b/doc/tutorial.rst index eeacb69e9..da715c963 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -728,7 +728,7 @@ location (x,y) in the image:: typedef value_type const_reference; typedef point_t argument_type; typedef reference result_type; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; mandelbrot_fn() {} mandelbrot_fn(const point_t& sz) : _img_size(sz) {} diff --git a/example/mandelbrot.cpp b/example/mandelbrot.cpp index f2b35f04f..65bf89afe 100644 --- a/example/mandelbrot.cpp +++ b/example/mandelbrot.cpp @@ -24,7 +24,7 @@ struct mandelbrot_fn using const_reference = value_type; using argument_type = point_t; using result_type = reference; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable =false; value_type _in_color,_out_color; point_t _img_size; diff --git a/include/boost/gil/bit_aligned_pixel_iterator.hpp b/include/boost/gil/bit_aligned_pixel_iterator.hpp index 2994cd57f..327f89fb2 100644 --- a/include/boost/gil/bit_aligned_pixel_iterator.hpp +++ b/include/boost/gil/bit_aligned_pixel_iterator.hpp @@ -69,7 +69,7 @@ public: bit_range_t& bit_range() { return _bit_range; } private: bit_range_t _bit_range; - BOOST_STATIC_CONSTANT(int, bit_size = NonAlignedPixelReference::bit_size); + static int constexpr bit_size = NonAlignedPixelReference::bit_size; friend class boost::iterator_core_access; reference dereference() const { return NonAlignedPixelReference(_bit_range); } diff --git a/include/boost/gil/bit_aligned_pixel_reference.hpp b/include/boost/gil/bit_aligned_pixel_reference.hpp index 6b7988cc3..93b1a5907 100644 --- a/include/boost/gil/bit_aligned_pixel_reference.hpp +++ b/include/boost/gil/bit_aligned_pixel_reference.hpp @@ -110,12 +110,22 @@ public: /// /// \ingroup ColorBaseModelNonAlignedPixel PixelModelNonAlignedPixel PixelBasedModel /// \brief Heterogeneous pixel reference corresponding to non-byte-aligned bit range. Models ColorBaseConcept, PixelConcept, PixelBasedConcept -template - typename Layout, - bool IsMutable> -struct bit_aligned_pixel_reference { - BOOST_STATIC_CONSTANT(int, bit_size = (mpl::accumulate, mpl::plus >::type::value)); +/// +/// \tparam BitField +/// \tparam ChannelBitSizes MPL integral vector defining the number of bits for each channel. For example, for 565RGB, vector_c +/// \tparam Layout +/// \tparam IsMutable +template +struct bit_aligned_pixel_reference +{ + static int constexpr bit_size = + mpl::accumulate + < + ChannelBitSizes, + mpl::int_<0>, + mpl::plus + >::type::value; + using bit_range_t = boost::gil::bit_range; using bitfield_t = BitField; using data_ptr_t =typename mpl::if_c::type; @@ -126,7 +136,7 @@ struct bit_aligned_pixel_reference { using reference = const bit_aligned_pixel_reference; using const_reference = bit_aligned_pixel_reference const; - BOOST_STATIC_CONSTANT(bool, is_mutable = IsMutable); + static bool constexpr is_mutable = IsMutable; bit_aligned_pixel_reference(){} bit_aligned_pixel_reference(data_ptr_t data_ptr, int bit_offset) : _bit_range(data_ptr, bit_offset) {} diff --git a/include/boost/gil/channel.hpp b/include/boost/gil/channel.hpp index 224eae4e7..ad0f5c372 100644 --- a/include/boost/gil/channel.hpp +++ b/include/boost/gil/channel.hpp @@ -79,7 +79,7 @@ namespace detail { using pointer = typename T::pointer; using const_reference = typename T::const_reference; using const_pointer = typename T::const_pointer; - BOOST_STATIC_CONSTANT(bool, is_mutable=T::is_mutable); + static bool constexpr is_mutable = T::is_mutable; static value_type min_value() { return T::min_value(); } static value_type max_value() { return T::max_value(); } }; @@ -92,7 +92,7 @@ namespace detail { using pointer = T*; using const_reference = T const&; using const_pointer = T const*; - BOOST_STATIC_CONSTANT(bool, is_mutable=true); + static bool constexpr is_mutable = true; static value_type min_value() { return (std::numeric_limits::min)(); } static value_type max_value() { return (std::numeric_limits::max)(); } }; @@ -102,7 +102,7 @@ namespace detail { struct channel_traits_impl : public channel_traits_impl { using reference = const T &; using pointer = const T *; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; }; } @@ -131,10 +131,12 @@ struct channel_traits : public detail::channel_traits_impl::value template struct channel_traits : public channel_traits {}; // Channel traits for constant C++ reference type -template struct channel_traits : public channel_traits { +template +struct channel_traits : public channel_traits +{ using reference = typename channel_traits::const_reference; using pointer = typename channel_traits::const_pointer; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; }; /////////////////////////////////////////// @@ -163,15 +165,18 @@ template struct channel_traits : public channel_traits /// \ingroup ScopedChannelValue /// \brief A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept -template // classes with a static apply() function returning the minimum/maximum channel values -struct scoped_channel_value { +/// \tparam BaseChannelValue base channel (models ChannelValueConcept) +/// \tparam MinVal class with a static apply() function returning the minimum channel values +/// \tparam MaxVal class with a static apply() function returning the maximum channel values +template +struct scoped_channel_value +{ using value_type = scoped_channel_value; using reference = value_type&; using pointer = value_type*; using const_reference = value_type const&; using const_pointer = value_type const*; - BOOST_STATIC_CONSTANT(bool, is_mutable=channel_traits::is_mutable); + static bool constexpr is_mutable = channel_traits::is_mutable; using base_channel_t = BaseChannelValue; @@ -275,16 +280,15 @@ public: using const_reference = value_type const&; using pointer = value_type*; using const_pointer = value_type const*; + static bool constexpr is_mutable = true; static value_type min_value() { return 0; } static value_type max_value() { return low_bits_mask_t< NumBits >::sig_bits; } - BOOST_STATIC_CONSTANT(bool, is_mutable=true); - packed_channel_value() {} - packed_channel_value(integer_t v) { _value = static_cast< integer_t >( v & low_bits_mask_t::sig_bits_fast ); } - template packed_channel_value(Scalar v) { _value = packed_channel_value( static_cast< integer_t >( v ) ); } + template + packed_channel_value(Scalar v) { _value = packed_channel_value( static_cast< integer_t >( v ) ); } static unsigned int num_bits() { return NumBits; } @@ -319,8 +323,8 @@ public: using reference = const Derived; using pointer = value_type *; using const_pointer = const value_type *; - BOOST_STATIC_CONSTANT(int, num_bits=NumBits); - BOOST_STATIC_CONSTANT(bool, is_mutable=Mutable); + static int constexpr num_bits = NumBits; + static bool constexpr is_mutable = Mutable; static value_type min_value() { return channel_traits::min_value(); } static value_type max_value() { return channel_traits::max_value(); } diff --git a/include/boost/gil/color_base_algorithm.hpp b/include/boost/gil/color_base_algorithm.hpp index fab4161ce..031a24c68 100644 --- a/include/boost/gil/color_base_algorithm.hpp +++ b/include/boost/gil/color_base_algorithm.hpp @@ -78,26 +78,43 @@ red_channel = channel_traits::max_value(); */ /// \brief Specifies the type of the K-th semantic element of a color base /// \ingroup ColorBaseAlgorithmSemanticAtC -template struct kth_semantic_element_type { - BOOST_STATIC_CONSTANT(int, semantic_index = (mpl::at_c::type::value)); +template +struct kth_semantic_element_type +{ + static int constexpr semantic_index = + mpl::at_c::type::value; using type = typename kth_element_type::type; }; /// \brief Specifies the return type of the mutable semantic_at_c(color_base); /// \ingroup ColorBaseAlgorithmSemanticAtC -template struct kth_semantic_element_reference_type { - BOOST_STATIC_CONSTANT(int, semantic_index = (mpl::at_c::type::value)); +template +struct kth_semantic_element_reference_type +{ + static int constexpr semantic_index = + mpl::at_c + < + typename ColorBase::layout_t::channel_mapping_t, + K + >::type::value; + using type = typename kth_element_reference_type::type; - static type get(ColorBase& cb) { return gil::at_c(cb); } + static type get(ColorBase& cb) { return gil::at_c(cb); } }; /// \brief Specifies the return type of the constant semantic_at_c(color_base); /// \ingroup ColorBaseAlgorithmSemanticAtC template struct kth_semantic_element_const_reference_type { - BOOST_STATIC_CONSTANT(int, semantic_index = (mpl::at_c::type::value)); + static int constexpr semantic_index = + mpl::at_c + < + typename ColorBase::layout_t::channel_mapping_t, + K + >::type::value; + using type = typename kth_element_const_reference_type::type; - static type get(const ColorBase& cb) { return gil::at_c(cb); } + static type get(const ColorBase& cb) { return gil::at_c(cb); } }; /// \brief A mutable accessor to the K-th semantic element of a color base 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 4ad151959..32293f04b 100644 --- a/include/boost/gil/extension/toolbox/image_types/subchroma_image.hpp +++ b/include/boost/gil/extension/toolbox/image_types/subchroma_image.hpp @@ -47,18 +47,25 @@ struct scaling_factors > >::type::value, ""); - BOOST_STATIC_CONSTANT( int, ss_X = ( mpl::divides< mpl::int_< J > - , mpl::int_ - >::type::value ) - ); + static int constexpr ss_X = + mpl::divides + < + mpl::int_, + mpl::int_ + >::type::value; - BOOST_STATIC_CONSTANT( int, ss_Y = (mpl::if_< mpl::equal_to< mpl::int_, mpl::int_< 0 > > - , mpl::int_< 2 > - , typename mpl::if_< mpl::equal_to< mpl::int_, mpl::int_ > - , mpl::int_< 1 > - , mpl::int_< 4 > - >::type - >::type::value)); + static int constexpr ss_Y = + mpl::if_ + < + mpl::equal_to, mpl::int_<0>>, + mpl::int_<2>, + typename mpl::if_ + < + mpl::equal_to, mpl::int_>, + mpl::int_<1>, + mpl::int_<4> + >::type + >::type::value; }; } // namespace detail diff --git a/include/boost/gil/image_view_factory.hpp b/include/boost/gil/image_view_factory.hpp index b0cfc9c8a..ffa91122a 100644 --- a/include/boost/gil/image_view_factory.hpp +++ b/include/boost/gil/image_view_factory.hpp @@ -312,16 +312,18 @@ namespace detail { template struct __nth_channel_view; // For basic (memory-based) views dispatch to __nth_channel_view_basic - template struct __nth_channel_view { + template + struct __nth_channel_view + { private: using src_x_iterator = typename View::x_iterator; // Determines whether the channels of a given pixel iterator are adjacent in memory. // Planar and grayscale iterators have channels adjacent in memory, whereas multi-channel interleaved and iterators with non-fundamental step do not. - BOOST_STATIC_CONSTANT(bool, adjacent= - !iterator_is_step::value && - (is_planar::value || - num_channels::value==1)); + static bool constexpr adjacent = + !iterator_is_step::value && + (is_planar::value || num_channels::value == 1); + public: using type = typename __nth_channel_view_basic::type; @@ -336,8 +338,10 @@ namespace detail { /// If the input is a pixel value or constant reference, the function object is immutable. Otherwise it is mutable (and returns non-const reference to the n-th channel) template // SrcP is a reference to PixelConcept (could be pixel value or const/non-const reference) // Examples: pixel, pixel&, const pixel&, planar_pixel_reference, planar_pixel_reference - struct nth_channel_deref_fn { - BOOST_STATIC_CONSTANT(bool, is_mutable=pixel_is_reference::value && pixel_reference_is_mutable::value); + struct nth_channel_deref_fn + { + static bool constexpr is_mutable = + pixel_is_reference::value && pixel_reference_is_mutable::value; private: using src_pixel_t = typename remove_reference::type; using channel_t = typename channel_type::type; @@ -443,16 +447,17 @@ namespace detail { template struct __kth_channel_view; // For basic (memory-based) views dispatch to __kth_channel_view_basic - template struct __kth_channel_view { + template struct __kth_channel_view + { private: using src_x_iterator = typename View::x_iterator; // Determines whether the channels of a given pixel iterator are adjacent in memory. // Planar and grayscale iterators have channels adjacent in memory, whereas multi-channel interleaved and iterators with non-fundamental step do not. - BOOST_STATIC_CONSTANT(bool, adjacent= - !iterator_is_step::value && - (is_planar::value || - num_channels::value==1)); + static bool constexpr adjacent = + !iterator_is_step::value && + (is_planar::value || num_channels::value == 1); + public: using type = typename __kth_channel_view_basic::type; @@ -465,15 +470,20 @@ namespace detail { /// \ingroup PixelDereferenceAdaptorModel /// /// If the input is a pixel value or constant reference, the function object is immutable. Otherwise it is mutable (and returns non-const reference to the k-th channel) - template // SrcP is a reference to PixelConcept (could be pixel value or const/non-const reference) - // Examples: pixel, pixel&, const pixel&, planar_pixel_reference, planar_pixel_reference - struct kth_channel_deref_fn { - BOOST_STATIC_CONSTANT(bool, is_mutable=pixel_is_reference::value && pixel_reference_is_mutable::value); + /// \tparam SrcP reference to PixelConcept (could be pixel value or const/non-const reference) + /// Examples: pixel, pixel&, const pixel&, planar_pixel_reference, planar_pixel_reference + template + struct kth_channel_deref_fn + { + static bool constexpr is_mutable = + pixel_is_reference::value && pixel_reference_is_mutable::value; + private: using src_pixel_t = typename remove_reference::type; using channel_t = typename kth_element_type::type; using const_ref_t = typename src_pixel_t::const_reference; using ref_t = typename pixel_reference_type::type; + public: using const_t = kth_channel_deref_fn; using value_type = typename pixel_value_type::type; diff --git a/include/boost/gil/io/base.hpp b/include/boost/gil/io/base.hpp index 84e6df819..6ac14cb71 100644 --- a/include/boost/gil/io/base.hpp +++ b/include/boost/gil/io/base.hpp @@ -92,10 +92,10 @@ struct property_base } // namespace detail -struct read_support_true { BOOST_STATIC_CONSTANT( bool, is_supported = true ); }; -struct read_support_false { BOOST_STATIC_CONSTANT( bool, is_supported = false ); }; -struct write_support_true { BOOST_STATIC_CONSTANT( bool, is_supported = true ); }; -struct write_support_false{ BOOST_STATIC_CONSTANT( bool, is_supported = false ); }; +struct read_support_true { static bool constexpr is_supported = true; }; +struct read_support_false { static bool constexpr is_supported = false; }; +struct write_support_true { static bool constexpr is_supported = true; }; +struct write_support_false{ static bool constexpr is_supported = false; }; class no_log {}; diff --git a/include/boost/gil/metafunctions.hpp b/include/boost/gil/metafunctions.hpp index 1b7c5a627..895a21a9c 100644 --- a/include/boost/gil/metafunctions.hpp +++ b/include/boost/gil/metafunctions.hpp @@ -321,13 +321,27 @@ struct packed_image5_type : public packed_image_type > -struct bit_aligned_image_type { +/// +template +< + typename ChannelBitSizeVector, + typename Layout, + typename Alloc = std::allocator +> +struct bit_aligned_image_type +{ private: - BOOST_STATIC_CONSTANT(int, bit_size = (mpl::accumulate, mpl::plus >::type::value)); + static int constexpr bit_size = + mpl::accumulate + < + ChannelBitSizeVector, + mpl::int_<0>, + mpl::plus + >::type::value; + using bitfield_t = typename detail::min_fast_uint::type; using bit_alignedref_t = bit_aligned_pixel_reference const; + public: using type = image; }; diff --git a/include/boost/gil/packed_pixel.hpp b/include/boost/gil/packed_pixel.hpp index d6c8f09af..4e33ef275 100644 --- a/include/boost/gil/packed_pixel.hpp +++ b/include/boost/gil/packed_pixel.hpp @@ -57,7 +57,8 @@ struct packed_pixel using reference = value_type&; using const_reference = value_type const&; - BOOST_STATIC_CONSTANT(bool, is_mutable = channel_traits::type>::is_mutable); + static bool constexpr is_mutable = + channel_traits::type>::is_mutable; packed_pixel(){} explicit packed_pixel(const BitField& bitfield) : _bitfield(bitfield) {} diff --git a/include/boost/gil/pixel.hpp b/include/boost/gil/pixel.hpp index 111fa389e..886adfc79 100644 --- a/include/boost/gil/pixel.hpp +++ b/include/boost/gil/pixel.hpp @@ -98,7 +98,7 @@ public: using value_type = pixel; using reference = value_type&; using const_reference = value_type const&; - BOOST_STATIC_CONSTANT(bool, is_mutable = channel_traits::is_mutable); + static bool constexpr is_mutable = channel_traits::is_mutable; pixel(){} explicit pixel(channel_t v) : parent_t(v) {} // sets all channels to v diff --git a/include/boost/gil/planar_pixel_reference.hpp b/include/boost/gil/planar_pixel_reference.hpp index 386c07760..0495f9701 100644 --- a/include/boost/gil/planar_pixel_reference.hpp +++ b/include/boost/gil/planar_pixel_reference.hpp @@ -42,8 +42,9 @@ private: // These three are only defined for homogeneous pixels using channel_t = typename channel_traits::value_type; using channel_const_reference = typename channel_traits::const_reference; + public: - BOOST_STATIC_CONSTANT(bool, is_mutable = channel_traits::is_mutable); + static bool constexpr is_mutable = channel_traits::is_mutable; using value_type = pixel>; using reference = planar_pixel_reference; using const_reference = planar_pixel_reference; diff --git a/include/boost/gil/premultiply.hpp b/include/boost/gil/premultiply.hpp index 32480d8f0..043431ea5 100644 --- a/include/boost/gil/premultiply.hpp +++ b/include/boost/gil/premultiply.hpp @@ -78,7 +78,7 @@ public: using const_reference = const value_type &; using argument_type = SrcConstRefP; using result_type = reference; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; result_type operator()(argument_type srcP) const { diff --git a/include/boost/gil/utilities.hpp b/include/boost/gil/utilities.hpp index 77063545d..5758c4249 100644 --- a/include/boost/gil/utilities.hpp +++ b/include/boost/gil/utilities.hpp @@ -94,7 +94,7 @@ struct deref_base using value_type = Value; using reference = Reference; using const_reference = ConstReference; - BOOST_STATIC_CONSTANT(bool, is_mutable = IsMutable); + static bool constexpr is_mutable = IsMutable; }; /// \brief Composes two dereference function objects. Similar to std::unary_compose but needs to pull some aliases from the component types. Models: PixelDereferenceAdaptorConcept diff --git a/io/test/mandel_view.hpp b/io/test/mandel_view.hpp index 81bf573c6..f1100f913 100644 --- a/io/test/mandel_view.hpp +++ b/io/test/mandel_view.hpp @@ -25,7 +25,7 @@ struct mandelbrot_fn using const_reference = value_type; using argument_type = point_t; using result_type = reference; - BOOST_STATIC_CONSTANT(bool, is_mutable = false); + static bool constexpr is_mutable = false; value_type _in_color,_out_color; point_t _img_size; diff --git a/test/channel.cpp b/test/channel.cpp index 4502ce882..f99fdf5f9 100644 --- a/test/channel.cpp +++ b/test/channel.cpp @@ -296,7 +296,7 @@ struct channel_archetype { using const_reference = channel_archetype const; using pointer = channel_value_archetype *; using const_pointer = channel_value_archetype const*; - BOOST_STATIC_CONSTANT(bool, is_mutable=true); + static bool constexpr is_mutable=true; static value_type min_value(); static value_type max_value(); diff --git a/test/channel/channel_concepts.cpp b/test/channel/channel_concepts.cpp index 60bb34e4b..114384503 100644 --- a/test/channel/channel_concepts.cpp +++ b/test/channel/channel_concepts.cpp @@ -52,7 +52,7 @@ struct channel_archetype using const_reference = channel_archetype const; using pointer = channel_value_archetype*; using const_pointer = channel_value_archetype const*; - BOOST_STATIC_CONSTANT(bool, is_mutable=true); + static bool constexpr is_mutable = true; static value_type min_value(); static value_type max_value(); diff --git a/test/image.cpp b/test/image.cpp index cc1c53903..45d1311ae 100644 --- a/test/image.cpp +++ b/test/image.cpp @@ -82,9 +82,11 @@ struct my_color_converter { } }; -// Models a Unary Function -template // Models PixelValueConcept -struct mandelbrot_fn { +/// Models a Unary Function +/// \tparam P models PixelValueConcept +template +struct mandelbrot_fn +{ using point_t = boost::gil::point_t; using const_t = mandelbrot_fn

; using value_type = P; @@ -92,7 +94,7 @@ struct mandelbrot_fn { using const_reference = value_type; using argument_type = point_t; using result_type = reference; - BOOST_STATIC_CONSTANT(bool, is_mutable=false); + static bool constexpr is_mutable = false; value_type _in_color,_out_color; point_t _img_size;