CPP08 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
easyfind.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* easyfind.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/08/21 23:33:48 by kamitsui #+# #+# */
9/* Updated: 2025/08/21 23:39:54 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
18#ifndef EASYFIND_HPP
19#define EASYFIND_HPP
20
21#include <algorithm> // For std::find
22#include <iostream> // For debugging or logging if needed
23#include <stdexcept> // For std::exception
24
25/*
26 * @class NotFoundException
27 * @brief Custom exception thrown when an element is not found in a container.
28 * @details Inherits std::exception and overrides the what() method to provide concrete error messages.
29 */
31 public:
36 virtual const char *what() const throw() { return "Element not found in container"; }
37};
38
39/*
40 * @brief Finds the first occurrence of a value in a container.
41 * @tparam T The type of the container. Must support iterators.
42 * @param container The container to search in.
43 * @param value The integer value to find.
44 * @return An iterator to the first element found.
45 * @throw NotFoundException if the value is not found in the container.
46 */
47template <typename T> typename T::iterator easyfind(T &container, int value);
48
49// Include the template implementation file
50#include "easyfind.tpp"
51
52#endif
virtual const char * what() const
Return an error message.
Definition easyfind.hpp:36
T::iterator easyfind(T &container, int value)