aboutsummaryrefslogtreecommitdiff
path: root/cpp07/ex01/iter.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp07/ex01/iter.hpp')
-rw-r--r--cpp07/ex01/iter.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/cpp07/ex01/iter.hpp b/cpp07/ex01/iter.hpp
new file mode 100644
index 0000000..df1a37a
--- /dev/null
+++ b/cpp07/ex01/iter.hpp
@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* iter.hpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/12/14 15:06:48 by cacharle #+# #+# */
+/* Updated: 2020/12/14 15:18:09 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef ITER_HPP
+# define ITER_HPP
+
+# include <iostream>
+
+template<typename T>
+void iter(T* ptr, size_t len, void (*f)(T const& x))
+{
+ for (size_t i = 0; i < len; i++)
+ f(ptr[i]);
+}
+
+template<typename T>
+void timeTwo(T const& x)
+{
+ std::cout << "timeTwo function " << x << " * 2 = " << x * 2 << std::endl;
+}
+
+#endif