arm_compute v17.05
[platform/upstream/armcl.git] / arm_compute / core / Helpers.h
index 44cf30c..a84ce2c 100644 (file)
@@ -108,11 +108,10 @@ inline uint8_t delta_bilinear_c1u8(const uint8_t *pixel_ptr, size_t stride, floa
  *
  * @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.
  */
@@ -184,13 +183,26 @@ inline void for_each(F &&func, T &&arg, Ts &&... args)
     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
@@ -198,10 +210,10 @@ inline T foldl(F &&, T &&value)
  * @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)...);
 }
 }