Skip to content

Commit

Permalink
use ::std for tolower, include <cctype>
Browse files Browse the repository at this point in the history
Some C++ compilers don't export C functions into `::` scope. This makes
`tolower` accessible to those compilers. Also, add `include <cctype>` to
make sure we are pulling in a header that contains it.

References:
* https://en.cppreference.com/w/cpp/header#C_compatibility_headers
* http://www.cplusplus.com/reference/cctype/
  • Loading branch information
girtsf authored and horenmar committed Feb 19, 2019
1 parent a6dfbbd commit e306107
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/clara.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "clara_textflow.hpp"

#include <cctype>
#include <vector>
#include <memory>
#include <sstream>
Expand Down Expand Up @@ -324,7 +325,7 @@ namespace detail {
}
inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {
std::string srcLC = source;
std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( ::tolower(c) ); } );
std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( std::tolower(c) ); } );
if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on")
target = true;
else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")
Expand Down

0 comments on commit e306107

Please sign in to comment.