August 2017
Intermediate to advanced
438 pages
14h 19m
English
Here are different ways to do case-insensitive comparisons:
#include <boost/algorithm/string/predicate.hpp> const bool solution_1 = ( boost::iequals(str1, str2));
#include <boost/algorithm/string/compare.hpp> #include <algorithm> const bool solution_2 = ( str1.size() == str2.size() && std::equal( str1.begin(), str1.end(), str2.begin(), boost::is_iequal() ));
#include <boost/algorithm/string/case_conv.hpp> void solution_3() { std::string str1_low = boost::to_lower_copy(str1); std::string str2_low = boost::to_lower_copy(str2); assert(str1_low == str2_low);}
Read now
Unlock full access