aboutsummaryrefslogtreecommitdiff
path: root/cpp07/ex01/iter.hpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-12-14 15:30:28 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-12-14 15:30:28 +0100
commit1de596dd9242b677d6b47b51db98ce98feb95465 (patch)
treeacbc79883c0af843b8b999a39f96cefd48e6e390 /cpp07/ex01/iter.hpp
parentb13cd117a7957f9d86ec2986b47349979325a854 (diff)
downloadpiscine_cpp-1de596dd9242b677d6b47b51db98ce98feb95465.tar.gz
piscine_cpp-1de596dd9242b677d6b47b51db98ce98feb95465.tar.bz2
piscine_cpp-1de596dd9242b677d6b47b51db98ce98feb95465.zip
Updated cpp07 files with new subject
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