*
* @warning Only works if the iterator was created with an IImage
*
- * @param[in[ first_pixel_ptr Pointer to the first pixel of a single channel U8 image.
- * @param[in[ stride Stride in bytes of the image;
- *
- * @param[in] x X position of the wanted pixel
- * @param[in] y Y position of the wanted pixel
+ * @param[in] first_pixel_ptr Pointer to the first pixel of a single channel U8 image.
+ * @param[in] stride Stride in bytes of the image;
+ * @param[in] x X position of the wanted pixel
+ * @param[in] y Y position of the wanted pixel
*
* @return The pixel at (x, y) using bilinear interpolation.
*/
for_each(func, args...);
}
-/** Base case of foldl. Return value. */
+/** Base case of foldl.
+ *
+ * @return value.
+ */
template <typename F, typename T>
-inline T foldl(F &&, T &&value)
+inline T foldl(F &&, const T &value)
{
return value;
}
+/** Base case of foldl.
+ *
+ * @return Function evaluation for value1 and value2
+ */
+template <typename F, typename T, typename U>
+inline auto foldl(F &&func, T &&value1, U &&value2) -> decltype(func(value1, value2))
+{
+ return func(value1, value2);
+}
+
/** Fold left.
*
* @param[in] func Function to be called
* @param[in] value Argument passed to the function
* @param[in] values Remaining arguments
*/
-template <typename F, typename I, typename T, typename... Ts>
-inline I foldl(F &&func, I &&initial, T &&value, Ts &&... values)
+template <typename F, typename I, typename T, typename... Vs>
+inline I foldl(F &&func, I &&initial, T &&value, Vs &&... values)
{
- return foldl(func, func(initial, value), values...);
+ return foldl(std::forward<F>(func), func(std::forward<I>(initial), std::forward<T>(value)), std::forward<Vs>(values)...);
}
}