Main MRPT website > C++ reference
MRPT logo
ci_less.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <functional> // binary_function
12 #include <cctype> // tolower
13 #include <string>
14 
15 namespace mrpt
16 {
17  namespace utils
18  {
19  /** \addtogroup stlext_grp STL extensions and metaprogramming
20  * \ingroup mrpt_base_grp
21  * @{ */
22 
23  /** A case-insensitive comparator struct for usage within STL containers, eg: map<string,string,ci_less>
24  */
25  struct ci_less : std::binary_function<std::string,std::string,bool>
26  {
27  // case-independent (ci) compare_less binary function
28  struct nocase_compare : public std::binary_function<char,char,bool> {
29  bool operator()(const char c1, const char c2) const { return tolower(c1)<tolower(c2); }
30  };
31  bool operator() (const std::string & s1, const std::string & s2) const {
32  return std::lexicographical_compare(s1.begin(),s1.end(), s2.begin(),s2.end(), nocase_compare());
33  }
34  }; // end of ci_less
35 
36  /** @} */ // end of grouping
37  } // End of namespace
38 } // End of namespace
A case-insensitive comparator struct for usage within STL containers, eg: map
Definition: ci_less.h:25
bool operator()(const char c1, const char c2) const
Definition: ci_less.h:29
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool operator()(const std::string &s1, const std::string &s2) const
Definition: ci_less.h:31



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.0 SVN: at Sun Sep 13 03:55:12 UTC 2015