cpp08/ex00/Easyfind.hpp

17 lines
298 B
C++

#ifndef EASYFIND_HPP
#define EASYFIND_HPP
#include <algorithm>
#include <exception>
template <typename T>
typename T::iterator easyfind(T &cont, int val)
{
typename T::iterator it = std::find(cont.begin(), cont.end(), val);
if (it == cont.end())
throw std::exception();
return it;
}
#endif