From 4115f22c50ee0571e88a8ec44c0241693af7ed38 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 15 Dec 2020 14:25:57 +0100 Subject: Fixing cpp08/{00,01} --- cpp08/ex00/easyfind.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cpp08/ex00/easyfind.hpp') diff --git a/cpp08/ex00/easyfind.hpp b/cpp08/ex00/easyfind.hpp index 68e176c..7523f53 100644 --- a/cpp08/ex00/easyfind.hpp +++ b/cpp08/ex00/easyfind.hpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/15 05:53:04 by charles #+# #+# */ -/* Updated: 2020/04/15 06:47:27 by charles ### ########.fr */ +/* Updated: 2020/12/15 11:58:54 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,9 +16,12 @@ # include template -typename T::iterator easyfind(T& container, int x) +int& easyfind(T& container, int x) { - return std::find(container.begin(), container.end(), x); + typename T::iterator found = std::find(container.begin(), container.end(), x); + if (found == container.end()) + throw std::exception(); + return *found; } #endif -- cgit