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.hpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/cpp07/ex01/iter.hpp b/cpp07/ex01/iter.hpp
index df1a37a..8118060 100644
--- a/cpp07/ex01/iter.hpp
+++ b/cpp07/ex01/iter.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/14 15:06:48 by cacharle #+# #+# */
-/* Updated: 2020/12/14 15:18:09 by cacharle ### ########.fr */
+/* Updated: 2020/12/15 11:23:16 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -23,9 +23,42 @@ void iter(T* ptr, size_t len, void (*f)(T const& x))
}
template<typename T>
+void iter(T* ptr, size_t len, void (*f)(T& x))
+{
+ for (size_t i = 0; i < len; i++)
+ f(ptr[i]);
+}
+
+template<typename T>
+void iter(T* ptr, size_t len, void (*f)(T 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;
}
+template<typename T>
+void timeThree(T& x)
+{
+ std::cout << "timeThree function " << x << " * 3 = " << x * 3 << std::endl;
+}
+
+class NotAnInt
+{
+public:
+ NotAnInt();
+ NotAnInt(int n);
+ NotAnInt(NotAnInt const& other);
+ NotAnInt& operator=(NotAnInt const& other);
+ int getN() const;
+
+private:
+ int m_n;
+};
+
#endif