d08 ex00 ok

This commit is contained in:
hugogogo
2022-03-13 18:33:48 +01:00
parent 96e78e34a1
commit a3be2c8f16
4 changed files with 183 additions and 0 deletions

24
d08/ex00/easyfind.hpp Normal file
View File

@@ -0,0 +1,24 @@
#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