d08 ex00 ok
This commit is contained in:
24
d08/ex00/easyfind.hpp
Normal file
24
d08/ex00/easyfind.hpp
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user