MRPT  1.9.9
ci_less.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <string>
12 
13 namespace mrpt::containers
14 {
15 /** A case-insensitive comparator class for use within STL containers, etc.
16  * \note Credits: https://stackoverflow.com/a/1801913/1631514
17  * \note This is the C++11 updated version of mrpt-1.x <mrpt/utils/ci_less.h>
18  * \ingroup mrpt_containers_grp
19  */
20 struct ci_less
21 {
23  {
24  bool operator()(const unsigned char& c1, const unsigned char& c2) const
25  {
26  return tolower(c1) < tolower(c2);
27  }
28  };
29  bool operator()(const std::string& s1, const std::string& s2) const
30  {
31  return std::lexicographical_compare(
32  s1.begin(), s1.end(), // source range
33  s2.begin(), s2.end(), // dest range
34  nocase_compare()); // comparison
35  }
36 };
37 
38 } // namespace mrpt::containers
bool operator()(const std::string &s1, const std::string &s2) const
Definition: ci_less.h:29
bool operator()(const unsigned char &c1, const unsigned char &c2) const
Definition: ci_less.h:24
A case-insensitive comparator class for use within STL containers, etc.
Definition: ci_less.h:20



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020