且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在不区分大小写的字符串向量中查找字符串C ++

更新时间:2023-11-15 09:10:58

或者,对于一个更小,更易于阅读的解决方案,Boost!

Or, for a much smaller and easier-to-read solution, Boost!

// #include <algorithm>
// #include <boost/algorithm/string/predicate.hpp>

const auto it = std::find_if(
   std::begin(vec),
   std::end(vec),
   [&myString](const auto& str) { return boost::iequals(myString, str); }
);

const bool found = (it != std::end(vec));