use std::any_of() algorithm instead of hand-rolled logic

This commit is contained in:
Dennis Luxen 2015-01-22 15:09:24 +01:00
parent e67f82283f
commit 887032881a

View File

@ -39,6 +39,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/ref.hpp> #include <boost/ref.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <algorithm>
namespace namespace
{ {
int lua_error_callback(lua_State *lua_state) int lua_error_callback(lua_State *lua_state)
@ -228,14 +230,16 @@ bool RestrictionParser::ShouldIgnoreRestriction(const std::string &except_tag_st
// only a few exceptions are actually defined. // only a few exceptions are actually defined.
std::vector<std::string> exceptions; std::vector<std::string> exceptions;
boost::algorithm::split_regex(exceptions, except_tag_string, boost::regex("[;][ ]*")); boost::algorithm::split_regex(exceptions, except_tag_string, boost::regex("[;][ ]*"));
for (std::string &current_string : exceptions)
{ return std::any_of(std::begin(exceptions), std::end(exceptions),
const auto string_iterator = [&](const std::string &current_string)
std::find(restriction_exceptions.begin(), restriction_exceptions.end(), current_string); {
if (restriction_exceptions.end() != string_iterator) if (restriction_exceptions.end() !=
{ std::find(restriction_exceptions.begin(),
return true; restriction_exceptions.end(), current_string))
} {
} return true;
return false; }
return false;
});
} }