mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 11:12:25 +01:00
fix implicit narrowing warnings in Catch
Catch passes ::tolower into std::transform with string iterators. ::tolower has the signature int(int), which triggers a stealth narrowing warning inside std::transform, because transform calls *_Dest = _Fn(*_First), which implicitly narrows an int to a char. For this particular application the narrowing is fine, so explicitly narrow in an inline function. This is identical to the issue that was fixed in pull request #728, just in a different place.
This commit is contained in:
parent
30cebd6177
commit
aaefa4e0e0
5
include/external/clara.h
vendored
5
include/external/clara.h
vendored
@ -396,9 +396,12 @@ namespace Clara {
|
|||||||
inline void convertInto( std::string const& _source, std::string& _dest ) {
|
inline void convertInto( std::string const& _source, std::string& _dest ) {
|
||||||
_dest = _source;
|
_dest = _source;
|
||||||
}
|
}
|
||||||
|
char toLowerCh(char c) {
|
||||||
|
return static_cast<char>(::tolower( c ));
|
||||||
|
}
|
||||||
inline void convertInto( std::string const& _source, bool& _dest ) {
|
inline void convertInto( std::string const& _source, bool& _dest ) {
|
||||||
std::string sourceLC = _source;
|
std::string sourceLC = _source;
|
||||||
std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower );
|
std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), tolowerCh );
|
||||||
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
|
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
|
||||||
_dest = true;
|
_dest = true;
|
||||||
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
|
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Catch v1.5.8
|
* Catch v1.5.8
|
||||||
* Generated: 2016-10-26 12:07:30.938259
|
* Generated: 2016-11-28 22:35:10.625000
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -3995,9 +3995,12 @@ namespace Clara {
|
|||||||
inline void convertInto( std::string const& _source, std::string& _dest ) {
|
inline void convertInto( std::string const& _source, std::string& _dest ) {
|
||||||
_dest = _source;
|
_dest = _source;
|
||||||
}
|
}
|
||||||
|
char toLowerCh(char c) {
|
||||||
|
return static_cast<char>(::tolower( c ));
|
||||||
|
}
|
||||||
inline void convertInto( std::string const& _source, bool& _dest ) {
|
inline void convertInto( std::string const& _source, bool& _dest ) {
|
||||||
std::string sourceLC = _source;
|
std::string sourceLC = _source;
|
||||||
std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower );
|
std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), tolowerCh );
|
||||||
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
|
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
|
||||||
_dest = true;
|
_dest = true;
|
||||||
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
|
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
|
||||||
|
Loading…
Reference in New Issue
Block a user