From 1de596dd9242b677d6b47b51db98ce98feb95465 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Mon, 14 Dec 2020 15:30:28 +0100 Subject: Updated cpp07 files with new subject --- cpp07/ex01/iter.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cpp07/ex01/iter.hpp (limited to 'cpp07/ex01/iter.hpp') 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 + +template +void iter(T* ptr, size_t len, void (*f)(T const& x)) +{ + for (size_t i = 0; i < len; i++) + f(ptr[i]); +} + +template +void timeTwo(T const& x) +{ + std::cout << "timeTwo function " << x << " * 2 = " << x * 2 << std::endl; +} + +#endif -- cgit