/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* iter.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bchanot +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/09 14:24:10 by bchanot #+# #+# */ /* Updated: 2026/01/09 18:42:40 by bchanot ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef ITER_HPP # define ITER_HPP # include # include template < typename T > void iter(T const *array, size_t size, void (*fn)(T const &)) { size_t i; i = 0; while (i < size) fn(array[i++]); } template < typename T > void iter(T const *array, size_t size, void (*fn)(T &)) { size_t i; T *tmp; tmp = const_cast(array); i = 0; while (i < size) fn(tmp[i++]); } template < typename T > void iter(T *array, size_t size, void (*fn)(T &)) { size_t i; i = 0; while (i < size) fn(array[i++]); } void print(int & value) { std::cout << "print " << value << std::endl; } template < typename T > void printConst(T const & value) { std::cout << "print " << value << std::endl; } template < typename T > void addTen(T & a) { a += 10; } #endif