Skip to content

Commit 0c6df6c

Browse files
committed
Refactor to trailing return types
- Trailing return types everywhere - Optionally, return type deduction where sensible (simple and short functions) This is related to introduction of common .clang-format, see boostorg#596 (comment)
1 parent bbdce36 commit 0c6df6c

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

include/boost/gil/algorithm.hpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,38 +83,38 @@ struct binary_operation_obj
8383
using result_type = Result;
8484

8585
template <typename V1, typename V2> BOOST_FORCEINLINE
86-
result_type operator()(const std::pair<const V1*,const V2*>& p) const {
86+
auto operator()(const std::pair<const V1*,const V2*>& p) const -> result_type {
8787
return apply(*p.first, *p.second, typename views_are_compatible<V1,V2>::type());
8888
}
8989

9090
template <typename V1, typename V2> BOOST_FORCEINLINE
91-
result_type operator()(const V1& v1, const V2& v2) const {
91+
auto operator()(const V1& v1, const V2& v2) const -> result_type {
9292
return apply(v1, v2, typename views_are_compatible<V1,V2>::type());
9393
}
9494

95-
result_type operator()(const error_t&) const { throw std::bad_cast(); }
95+
result_type operator()(const error_t&) const -> result_type { throw std::bad_cast(); }
9696
private:
9797

9898
// dispatch from apply overload to a function with distinct name
9999
template <typename V1, typename V2>
100100
BOOST_FORCEINLINE
101-
result_type apply(V1 const& v1, V2 const& v2, std::false_type) const
101+
auto apply(V1 const& v1, V2 const& v2, std::false_type) const -> result_type
102102
{
103103
return ((const Derived*)this)->apply_incompatible(v1, v2);
104104
}
105105

106106
// dispatch from apply overload to a function with distinct name
107107
template <typename V1, typename V2>
108108
BOOST_FORCEINLINE
109-
result_type apply(V1 const& v1, V2 const& v2, std::true_type) const
109+
auto apply(V1 const& v1, V2 const& v2, std::true_type) const -> result_type
110110
{
111111
return ((const Derived*)this)->apply_compatible(v1, v2);
112112
}
113113

114114
// function with distinct name - it can be overloaded by subclasses
115115
template <typename V1, typename V2>
116116
BOOST_FORCEINLINE
117-
result_type apply_incompatible(V1 const& /*v1*/, V2 const& /*v2*/) const
117+
auto apply_incompatible(V1 const& /*v1*/, V2 const& /*v2*/) const -> result_type
118118
{
119119
throw std::bad_cast();
120120
}
@@ -149,9 +149,10 @@ auto copy(
149149
/// \ingroup STLOptimizations
150150
/// \brief Copy when both src and dst are interleaved and of the same type can be just memmove
151151
template<typename T, typename CS>
152-
BOOST_FORCEINLINE boost::gil::pixel<T,CS>*
153-
copy(const boost::gil::pixel<T,CS>* first, const boost::gil::pixel<T,CS>* last,
154-
boost::gil::pixel<T,CS>* dst) {
152+
BOOST_FORCEINLINE
153+
auto copy(const boost::gil::pixel<T,CS>* first, const boost::gil::pixel<T,CS>* last,
154+
boost::gil::pixel<T,CS>* dst) -> boost::gil::pixel<T,CS>*
155+
{
155156
return (boost::gil::pixel<T,CS>*)std::copy((unsigned char*)first,(unsigned char*)last, (unsigned char*)dst);
156157
}
157158
} // namespace std
@@ -168,7 +169,8 @@ namespace std {
168169
/// \ingroup STLOptimizations
169170
/// \brief Copy when both src and dst are planar pointers is copy for each channel
170171
template<typename CS, typename IC1, typename IC2> BOOST_FORCEINLINE
171-
boost::gil::planar_pixel_iterator<IC2,CS> copy(boost::gil::planar_pixel_iterator<IC1,CS> first, boost::gil::planar_pixel_iterator<IC1,CS> last, boost::gil::planar_pixel_iterator<IC2,CS> dst) {
172+
auto copy(boost::gil::planar_pixel_iterator<IC1,CS> first, boost::gil::planar_pixel_iterator<IC1,CS> last, boost::gil::planar_pixel_iterator<IC2,CS> dst) -> boost::gil::planar_pixel_iterator<IC2,CS>
173+
{
172174
boost::gil::gil_function_requires<boost::gil::ChannelsCompatibleConcept<typename std::iterator_traits<IC1>::value_type,typename std::iterator_traits<IC2>::value_type>>();
173175
static_for_each(first,last,dst,boost::gil::detail::copy_fn<IC1,IC2>());
174176
return dst+(last-first);
@@ -244,7 +246,7 @@ struct copier_n<iterator_from_2d<IL>,iterator_from_2d<OL>> {
244246
};
245247

246248
template <typename SrcIterator, typename DstIterator>
247-
BOOST_FORCEINLINE DstIterator copy_with_2d_iterators(SrcIterator first, SrcIterator last, DstIterator dst) {
249+
BOOST_FORCEINLINE auto copy_with_2d_iterators(SrcIterator first, SrcIterator last, DstIterator dst) -> DstIterator {
248250
using src_x_iterator = typename SrcIterator::x_iterator;
249251
using dst_x_iterator = typename DstIterator::x_iterator;
250252

@@ -270,9 +272,11 @@ namespace std {
270272
/// \ingroup STLOptimizations
271273
/// \brief std::copy(I1,I1,I2) with I1 and I2 being a iterator_from_2d
272274
template <typename IL, typename OL>
273-
BOOST_FORCEINLINE boost::gil::iterator_from_2d<OL> copy1(boost::gil::iterator_from_2d<IL> first, boost::gil::iterator_from_2d<IL> last, boost::gil::iterator_from_2d<OL> dst) {
275+
BOOST_FORCEINLINE auto copy1(boost::gil::iterator_from_2d<IL> first, boost::gil::iterator_from_2d<IL> last, boost::gil::iterator_from_2d<OL> dst) -> boost::gil::iterator_from_2d<OL>
276+
{
274277
return boost::gil::detail::copy_with_2d_iterators(first,last,dst);
275278
}
279+
276280
} // namespace std
277281

278282
namespace boost { namespace gil {
@@ -307,13 +311,13 @@ class copy_and_convert_pixels_fn : public binary_operation_obj<copy_and_convert_
307311
copy_and_convert_pixels_fn(CC cc_in) : _cc(cc_in) {}
308312
// when the two color spaces are incompatible, a color conversion is performed
309313
template <typename V1, typename V2> BOOST_FORCEINLINE
310-
result_type apply_incompatible(const V1& src, const V2& dst) const {
314+
auto apply_incompatible(const V1& src, const V2& dst) const -> result_type {
311315
copy_pixels(color_converted_view<typename V2::value_type>(src,_cc),dst);
312316
}
313317

314318
// If the two color spaces are compatible, copy_and_convert is just copy
315319
template <typename V1, typename V2> BOOST_FORCEINLINE
316-
result_type apply_compatible(const V1& src, const V2& dst) const {
320+
auto apply_compatible(const V1& src, const V2& dst) const -> result_type {
317321
copy_pixels(src,dst);
318322
}
319323
};

0 commit comments

Comments
 (0)