From 7e87ecd7e3858c2d8a79b05f243849366829d98a Mon Sep 17 00:00:00 2001 From: Marco Langer Date: Tue, 5 Jul 2022 17:53:30 +0200 Subject: [PATCH] fix: wrong return type of copy_fn and missing typedef in destruct_range --- include/boost/gil/algorithm.hpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/include/boost/gil/algorithm.hpp b/include/boost/gil/algorithm.hpp index 2b61068830..6f5a0013e9 100644 --- a/include/boost/gil/algorithm.hpp +++ b/include/boost/gil/algorithm.hpp @@ -143,30 +143,24 @@ namespace std { template BOOST_FORCEINLINE auto copy( - boost::gil::pixel* first, - boost::gil::pixel* last, + boost::gil::pixel const* first, + boost::gil::pixel const* last, boost::gil::pixel* dst) -> boost::gil::pixel* { - auto p = std::copy((unsigned char*)first, (unsigned char*)last, (unsigned char*)dst); + auto p = std::copy( + reinterpret_cast(first), + reinterpret_cast(last), + reinterpret_cast(dst)); return reinterpret_cast*>(p); } -/// \ingroup STLOptimizations -/// \brief Copy when both src and dst are interleaved and of the same type can be just memmove -template -BOOST_FORCEINLINE -auto copy(const boost::gil::pixel* first, const boost::gil::pixel* last, - boost::gil::pixel* dst) -> boost::gil::pixel* -{ - return (boost::gil::pixel*)std::copy((unsigned char*)first,(unsigned char*)last, (unsigned char*)dst); -} } // namespace std namespace boost { namespace gil { namespace detail { template struct copy_fn { - BOOST_FORCEINLINE I operator()(I first, I last, O dst) const { return std::copy(first,last,dst); } + BOOST_FORCEINLINE O operator()(I first, I last, O dst) const { return std::copy(first,last,dst); } }; } // namespace detail } } // namespace boost::gil @@ -454,8 +448,9 @@ void destruct_range_impl(Iterator first, Iterator last, detail::is_trivially_destructible::value_type> > >::value - >::type* /*ptr*/ = 0) + >::type* /* ptr */ = nullptr) { + using value_t = typename std::iterator_traits::value_type; while (first != last) { first->~value_t();