aboutsummaryrefslogtreecommitdiff
path: root/cpp08/ex00/easyfind.hpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-12-15 14:25:57 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-12-15 14:25:57 +0100
commit4115f22c50ee0571e88a8ec44c0241693af7ed38 (patch)
tree9e702e34ba360aa5f10f8f84b37b97b6ca8dd731 /cpp08/ex00/easyfind.hpp
parent78efa932fb42289904fe542cfc152978397ae37c (diff)
downloadpiscine_cpp-4115f22c50ee0571e88a8ec44c0241693af7ed38.tar.gz
piscine_cpp-4115f22c50ee0571e88a8ec44c0241693af7ed38.tar.bz2
piscine_cpp-4115f22c50ee0571e88a8ec44c0241693af7ed38.zip
Fixing cpp08/{00,01}
Diffstat (limited to 'cpp08/ex00/easyfind.hpp')
-rw-r--r--cpp08/ex00/easyfind.hpp9
1 files changed, 6 insertions, 3 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <algorithm>
template<typename T>
-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