25 lines
1.2 KiB
C++
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;
|
|
}
|