diff --git a/include/boost/gil/channel_algorithm.hpp b/include/boost/gil/channel_algorithm.hpp index c1b23591..2a5d3d26 100644 --- a/include/boost/gil/channel_algorithm.hpp +++ b/include/boost/gil/channel_algorithm.hpp @@ -136,9 +136,11 @@ namespace detail { ////////////////////////////////////// /// \brief This is the default implementation. Performance specializatons are provided -template -struct channel_converter_unsigned_impl : public std::unary_function { - DstChannelV operator()(SrcChannelV src) const { +template +struct channel_converter_unsigned_impl { + typedef SrcChannelV argument_type; + typedef DstChannelV result_type; + DstChannelV operator()(SrcChannelV src) const { return DstChannelV(channel_traits::min_value() + (src - channel_traits::min_value()) / channel_range() * channel_range()); } @@ -273,7 +275,9 @@ struct channel_converter_unsigned_integral_nondivisible struct channel_converter_unsigned : public std::unary_function { +template struct channel_converter_unsigned { + typedef bits32f argument_type; + typedef DstChannelV result_type; DstChannelV operator()(bits32f x) const { typedef typename detail::unsigned_integral_max_value< DstChannelV >::value_type dst_integer_t; @@ -281,29 +285,37 @@ template struct channel_converter_unsigned struct channel_converter_unsigned : public std::unary_function { +template struct channel_converter_unsigned { + typedef bits32f argument_type; + typedef SrcChannelV result_type; bits32f operator()(SrcChannelV x) const { return bits32f(x/float(channel_traits::max_value())); } }; -template <> struct channel_converter_unsigned : public std::unary_function { +template <> struct channel_converter_unsigned { + typedef bits32f argument_type; + typedef bits32f result_type; bits32f operator()(bits32f x) const { return x; } }; /// \brief 32 bit <-> float channel conversion -template <> struct channel_converter_unsigned : public std::unary_function { - bits32f operator()(bits32 x) const { +template <> struct channel_converter_unsigned { + typedef bits32 argument_type; + typedef bits32f result_type; + bits32f operator()(bits32 x) const { // unfortunately without an explicit check it is possible to get a round-off error. We must ensure that max_value of bits32 matches max_value of bits32f if (x>=channel_traits::max_value()) return channel_traits::max_value(); return float(x) / float(channel_traits::max_value()); } }; /// \brief 32 bit <-> float channel conversion -template <> struct channel_converter_unsigned : public std::unary_function { - bits32 operator()(bits32f x) const { +template <> struct channel_converter_unsigned { + typedef bits32f argument_type; + typedef bits32 result_type; + bits32 operator()(bits32f x) const { // unfortunately without an explicit check it is possible to get a round-off error. We must ensure that max_value of bits32 matches max_value of bits32f if (x>=channel_traits::max_value()) return channel_traits::max_value(); - return bits32(x * channel_traits::max_value() + 0.5f); + return bits32(x * channel_traits::max_value() + 0.5f); } }; @@ -317,17 +329,23 @@ struct channel_convert_to_unsigned : public detail::identity { typedef ChannelValue type; }; -template <> struct channel_convert_to_unsigned : public std::unary_function { +template <> struct channel_convert_to_unsigned { + typedef bits8s argument_type; + typedef bits8 result_type; typedef bits8 type; - type operator()(bits8s val) const { return val+128; } + type operator()(bits8s val) const { return val+128; } }; -template <> struct channel_convert_to_unsigned : public std::unary_function { +template <> struct channel_convert_to_unsigned { + typedef bits16s argument_type; + typedef bits16 result_type; typedef bits16 type; - type operator()(bits16s val) const { return val+32768; } + type operator()(bits16s val) const { return val+32768; } }; -template <> struct channel_convert_to_unsigned : public std::unary_function { +template <> struct channel_convert_to_unsigned { + typedef bits32s argument_type; + typedef bits32 result_type; typedef bits32 type; type operator()(bits32s x) const { return static_cast(x+(1<<31)); } }; @@ -340,17 +358,23 @@ struct channel_convert_from_unsigned : public detail::identity { typedef ChannelValue type; }; -template <> struct channel_convert_from_unsigned : public std::unary_function { +template <> struct channel_convert_from_unsigned { + typedef bits8 argument_type; + typedef bits8s result_type; typedef bits8s type; - type operator()(bits8 val) const { return val-128; } + type operator()(bits8 val) const { return val-128; } }; -template <> struct channel_convert_from_unsigned : public std::unary_function { +template <> struct channel_convert_from_unsigned { + typedef bits16 argument_type; + typedef bits16s result_type; typedef bits16s type; - type operator()(bits16 val) const { return val-32768; } + type operator()(bits16 val) const { return val-32768; } }; -template <> struct channel_convert_from_unsigned : public std::unary_function { +template <> struct channel_convert_from_unsigned { + typedef bits32 argument_type; + typedef bits32s result_type; typedef bits32s type; type operator()(bits32 x) const { return static_cast(x-(1<<31)); } }; @@ -360,12 +384,14 @@ template <> struct channel_convert_from_unsigned : public std::unary_fu /// \ingroup ChannelConvertAlgorithm /// \brief A unary function object converting between channel types template // Model ChannelValueConcept -struct channel_converter : public std::unary_function { +struct channel_converter { + typedef SrcChannelV argument_type; + typedef DstChannelV result_type; DstChannelV operator()(const SrcChannelV& src) const { typedef detail::channel_convert_to_unsigned to_unsigned; typedef detail::channel_convert_from_unsigned from_unsigned; typedef channel_converter_unsigned converter_unsigned; - return from_unsigned()(converter_unsigned()(to_unsigned()(src))); + return from_unsigned()(converter_unsigned()(to_unsigned()(src))); } }; @@ -413,35 +439,50 @@ assert(mul == 64); // 64 = 128 * 128 / 255 /// \brief This is the default implementation. Performance specializatons are provided template -struct channel_multiplier_unsigned : public std::binary_function { +struct channel_multiplier_unsigned { + typedef ChannelValue first_argument_type; + typedef ChannelValue second_argument_type; + typedef ChannelValue result_type; ChannelValue operator()(ChannelValue a, ChannelValue b) const { return ChannelValue(static_cast::type>(a / double(channel_traits::max_value()) * b)); } }; /// \brief Specialization of channel_multiply for 8-bit unsigned channels -template<> struct channel_multiplier_unsigned : public std::binary_function { +template<> struct channel_multiplier_unsigned { + typedef bits8 first_argument_type; + typedef bits8 second_argument_type; + typedef bits8 result_type; bits8 operator()(bits8 a, bits8 b) const { return bits8(detail::div255(uint32_t(a) * uint32_t(b))); } }; /// \brief Specialization of channel_multiply for 16-bit unsigned channels -template<> struct channel_multiplier_unsigned : public std::binary_function { +template<> struct channel_multiplier_unsigned { + typedef bits16 first_argument_type; + typedef bits16 second_argument_type; + typedef bits16 result_type; bits16 operator()(bits16 a, bits16 b) const { return bits16((uint32_t(a) * uint32_t(b))/65535); } }; /// \brief Specialization of channel_multiply for float 0..1 channels -template<> struct channel_multiplier_unsigned : public std::binary_function { +template<> struct channel_multiplier_unsigned { + typedef bits32f first_argument_type; + typedef bits32f second_argument_type; + typedef bits32f result_type; bits32f operator()(bits32f a, bits32f b) const { return a*b; } }; /// \brief A function object to multiply two channels. result = a * b / max_value template -struct channel_multiplier : public std::binary_function { +struct channel_multiplier { + typedef ChannelValue first_argument_type; + typedef ChannelValue second_argument_type; + typedef ChannelValue result_type; ChannelValue operator()(ChannelValue a, ChannelValue b) const { typedef detail::channel_convert_to_unsigned to_unsigned; typedef detail::channel_convert_from_unsigned from_unsigned; typedef channel_multiplier_unsigned multiplier_unsigned; - return from_unsigned()(multiplier_unsigned()(to_unsigned()(a), to_unsigned()(b))); + return from_unsigned()(multiplier_unsigned()(to_unsigned()(a), to_unsigned()(b))); } }; diff --git a/include/boost/gil/gil_concept.hpp b/include/boost/gil/gil_concept.hpp index 6862fd71..7d5ac98f 100644 --- a/include/boost/gil/gil_concept.hpp +++ b/include/boost/gil/gil_concept.hpp @@ -1114,7 +1114,9 @@ struct PixelDereferenceAdaptorConcept { }; template -struct PixelDereferenceAdaptorArchetype : public std::unary_function { +struct PixelDereferenceAdaptorArchetype { + typedef P argument_type; + typedef P result_type; typedef PixelDereferenceAdaptorArchetype const_t; typedef typename remove_reference

::type value_type; typedef typename add_reference

::type reference; diff --git a/include/boost/gil/planar_pixel_iterator.hpp b/include/boost/gil/planar_pixel_iterator.hpp index 66689629..9585e845 100644 --- a/include/boost/gil/planar_pixel_iterator.hpp +++ b/include/boost/gil/planar_pixel_iterator.hpp @@ -114,7 +114,11 @@ struct planar_pixel_iterator : public iterator_facade()); } void decrement() { static_transform(*this,*this,detail::dec()); } - void advance(std::ptrdiff_t d) { static_transform(*this,*this,std::bind2nd(detail::plus_asymmetric(),d)); } +#ifdef BOOST_NO_CXX98_BINDERS + void advance(std::ptrdiff_t d){ static_transform(*this,*this,std::bind(detail::plus_asymmetric(),std::placeholders::_1,d)); } +#else + void advance(std::ptrdiff_t d){ static_transform(*this,*this,std::bind2nd(detail::plus_asymmetric(),d)); } +#endif reference dereference() const { return this->template deref(); } std::ptrdiff_t distance_to(const planar_pixel_iterator& it) const { return gil::at_c<0>(it)-gil::at_c<0>(*this); } diff --git a/include/boost/gil/utilities.hpp b/include/boost/gil/utilities.hpp index 0ccdae7f..274bdc3a 100644 --- a/include/boost/gil/utilities.hpp +++ b/include/boost/gil/utilities.hpp @@ -179,7 +179,9 @@ inline T align(T val, std::size_t alignment) { /// template -struct deref_base : public std::unary_function { +struct deref_base { + typedef ArgType argument_type; + typedef ResultType result_type; typedef ConstT const_t; typedef Value value_type; typedef Reference reference; @@ -259,8 +261,10 @@ copy_n(InputIter first, Size count, OutputIter result) { } /// \brief identity taken from SGI STL. -template -struct identity : public std::unary_function { +template +struct identity { + typedef T argument_type; + typedef T result_type; const T& operator()(const T& val) const { return val; } }; @@ -268,7 +272,10 @@ struct identity : public std::unary_function { /// \brief plus function object whose arguments may be of different type. template -struct plus_asymmetric : public std::binary_function { +struct plus_asymmetric { + typedef T1 first_argument_type; + typedef T2 second_argument_type; + typedef T1 result_type; T1 operator()(T1 f1, T2 f2) const { return f1+f2; } @@ -278,7 +285,9 @@ struct plus_asymmetric : public std::binary_function { /// \brief operator++ wrapped in a function object template -struct inc : public std::unary_function { +struct inc { + typedef T argument_type; + typedef T result_type; T operator()(T x) const { return ++x; } }; @@ -286,7 +295,9 @@ struct inc : public std::unary_function { /// \brief operator-- wrapped in a function object template -struct dec : public std::unary_function { +struct dec { + typedef T argument_type; + typedef T result_type; T operator()(T x) const { return --x; } };