1/* ************************************************************************** */
4/* easyfind.tpp :+: :+: :+: */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
8/* Created: 2025/08/22 00:03:07 by kamitsui #+# #+# */
9/* Updated: 2025/08/22 00:15:48 by kamitsui ### ########.fr */
11/* ************************************************************************** */
14 * @file ex00/easyfind.tpp
20#include "easyfind.hpp"
22template <typename T> typename T::iterator easyfind(T &container, int value) {
23 // Use the standard algorithm std::find to search for the value.
24 // std::find returns an iterator to the first occurrence of the value
25 // in the range [first, last).
26 typename T::iterator it = std::find(container.begin(), container.end(), value);
28 // If the returned iterator is equal to the container's end iterator,
29 // it means the value was not found.
30 if (it == container.end()) {
31 // In this case, throw our custom exception.
32 throw NotFoundException();
35 // Otherwise, return the iterator pointing to the found element.