You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
1.3 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* easyfind.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/19 08:06:39 by narnaud #+# #+# */
/* Updated: 2022/09/19 08:06:42 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <algorithm>
#include <exception>
#include <iostream>
#include <iterator>
template <class T>
typename T::iterator easyfind(T &t, const int nb) {
typename T::iterator it;
it = find(t.begin(), t.end(), nb);
if (it == t.end())
return (t.end());
return (it);
}
template <class T>
void is_easyfound(T it, T end) {
if (it != end)
std::cout << "You found: " << *it << std::endl;
else
std::cout << "You didn't found it." << std::endl;
}