aboutsummaryrefslogtreecommitdiff
path: root/cpp07/ex01
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-12-13 17:13:45 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-12-13 17:13:45 +0100
commit2ee90625e793175c5fcde47564326a7eb8a1b3ee (patch)
tree1896283aa0ea1b4b8a493fcd82be1c2eec39eeda /cpp07/ex01
parentd2d136a5810b8dc233b7a6260531e7fd0c138f3e (diff)
downloadpiscine_cpp-2ee90625e793175c5fcde47564326a7eb8a1b3ee.tar.gz
piscine_cpp-2ee90625e793175c5fcde47564326a7eb8a1b3ee.tar.bz2
piscine_cpp-2ee90625e793175c5fcde47564326a7eb8a1b3ee.zip
Added cpp06/ex00
Diffstat (limited to 'cpp07/ex01')
-rw-r--r--cpp07/ex01/iter.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/cpp07/ex01/iter.cpp b/cpp07/ex01/iter.cpp
index 80b29d3..831286f 100644
--- a/cpp07/ex01/iter.cpp
+++ b/cpp07/ex01/iter.cpp
@@ -6,23 +6,24 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 20:02:19 by charles #+# #+# */
-/* Updated: 2020/04/14 20:12:17 by charles ### ########.fr */
+/* Updated: 2020/12/11 15:45:09 by charles ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
template<typename T>
-void iter(T* ptr, size_t len, void (*f)(T* x))
+void iter(T* ptr, size_t len, void (*f)(T const& x))
{
for (size_t i = 0; i < len; i++)
- f(ptr + i);
+ f(ptr[i]);
}
+/* sel-melc says const& */
template<typename T>
-void timeTwo(T* x)
+void timeTwo(T const& x)
{
- *x *= 2;
+ x *= 2;
}
int main()