「✨」 feat: finished ex00
This commit is contained in:
24
ex00/easyfind.hpp
Normal file
24
ex00/easyfind.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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;
|
||||
}
|
Reference in New Issue
Block a user