/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bchanot +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/13 17:54:18 by bchanot #+# #+# */ /* Updated: 2026/01/13 18:03:54 by bchanot ### ########.fr */ /* */ /* ************************************************************************** */ #include #include #include template< typename T > std::vector::iterator easyFind(T & vec, int const & j) { std::vector::iterator it; for (it = std::begin(vec); it < std::end(vec); it++) { if (*it == j) return it; } throw std::exception(); } int main(void) { std::vector vec = {0, 23, 456, 67}; std::vector::iterator it; try { it = easyFind(vec, 22); std::cout << "Found ! it is : " << *it << std::endl; } catch (std::exception &e) { std::cout << "Didn't found the given int in the vec" << std::endl; } return 0; }