Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
to_lower.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/string/to_lower.cpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2007-2017 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #include <tlx/string/to_lower.hpp>
12 
13 #include <algorithm>
14 
15 namespace tlx {
16 
17 char to_lower(char ch) {
18  if (static_cast<unsigned>(ch - 'A') < 26u)
19  ch = static_cast<char>(ch - 'A' + 'a');
20  return ch;
21 }
22 
24  std::transform(str->begin(), str->end(), str->begin(),
25  [](char c) { return to_lower(c); });
26  return *str;
27 }
28 
30  std::string str_copy(str.size(), 0);
31  std::transform(str.begin(), str.end(), str_copy.begin(),
32  [](char c) { return to_lower(c); });
33  return str_copy;
34 }
35 
36 } // namespace tlx
37 
38 /******************************************************************************/
char to_lower(char ch)
Transform the given character to lower case without any localization.
Definition: to_lower.cpp:17
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220