1
0
Files
CPP_Module_08/ex00/easyfind.hpp
2025-04-14 19:39:20 +02:00

25 lines
1.2 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* easyfind.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 19:07:43 by adjoly #+# #+# */
/* Updated: 2025/04/14 19:33:52 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <algorithm>
#include <iterator>
#include <stdexcept>
template <typename T> typename T::iterator easyfind(T val, int what) {
typename T::iterator it = std::find(val.begin(), val.end(), what);
if (it == val.end())
throw std::runtime_error("value not found");
return it;
}