From 8fb0d5509cf29df52f6710a89076bd286b2d633d Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 26 Jul 2012 16:16:14 +0200 Subject: [PATCH] Bugfix: when retrieving the best element of an empty population eoPop, segfault. Fixed by launching an exception in this case. --- eo/src/eoPop.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index 3ea53f466..371fdfd01 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -201,6 +201,8 @@ public: #else typename eoPop::const_iterator it = std::max_element(begin(), end()); #endif + if( it == end() ) + throw std::runtime_error("eoPop: Empty population, when calling best_element()."); return (*it); }