MRPT
2.0.3
mrpt
containers
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
{
22
struct
nocase_compare
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
mrpt::containers::ci_less::nocase_compare::operator()
bool operator()(const unsigned char &c1, const unsigned char &c2) const
Definition:
ci_less.h:24
mrpt::containers::ci_less::operator()
bool operator()(const std::string &s1, const std::string &s2) const
Definition:
ci_less.h:29
mrpt::containers::ci_less::nocase_compare
Definition:
ci_less.h:22
mrpt::containers::ci_less
A case-insensitive comparator class for use within STL containers, etc.
Definition:
ci_less.h:20
mrpt::containers
Definition:
bimap.h:14
Page generated by
Doxygen 1.8.17
for MRPT 2.0.3 at Fri May 15 15:49:54 UTC 2020