Files
42_INT_09_piscine_cpp/d08/ex00/easyfind.hpp
2022-03-13 18:33:48 +01:00

25 lines
476 B
C++

#ifndef EASYFIND_HPP
# define EASYFIND_HPP
# include "colors.h"
# include <algorithm>
class easyfindException : public std::exception {
virtual char const *what(void) const throw() {
return "not found";
}
};
template < typename T >
typename T::const_iterator easyfind(T const & container, int nb) {
typename T::const_iterator it;
it = std::find(container.begin(), container.end(), nb);
if (it == container.end())
throw easyfindException();
return it;
}
#endif