| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* iter.hpp :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* 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 <iostream>
- # include <string>
- 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<T*>(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
|