Commit f24561f460aa840f280c103e85f824b2a23b5bdf

Authored by Henry Fredrick Schreiner
1 parent 786f99d0

Explicit casts

.clang-tidy
1 #Checks: '*,-clang-analyzer-alpha.*' 1 #Checks: '*,-clang-analyzer-alpha.*'
2 #Checks: '-*,google-readability-casting,llvm-namespace-comment,performance-unnecessary-value-param,llvm-include-order,misc-throw-by-value-catch-by-reference,readability-container-size-empty,google-runtime-references,modernize*' 2 #Checks: '-*,google-readability-casting,llvm-namespace-comment,performance-unnecessary-value-param,llvm-include-order,misc-throw-by-value-catch-by-reference,readability-container-size-empty,google-runtime-references,modernize*'
3 -Checks: '-*,llvm-namespace-comment,llvm-include-order,readability-container-size-empty,misc-throw-by-value-catch-by-reference,modernize*' 3 +Checks: '-*,llvm-namespace-comment,llvm-include-order,readability-container-size-empty,misc-throw-by-value-catch-by-reference,modernize*,google-readability-casting'
4 HeaderFilterRegex: '.*hpp' 4 HeaderFilterRegex: '.*hpp'
5 CheckOptions: 5 CheckOptions:
6 - key: readability-braces-around-statements.ShortStatementLines 6 - key: readability-braces-around-statements.ShortStatementLines
include/CLI/App.hpp
@@ -307,7 +307,7 @@ public: @@ -307,7 +307,7 @@ public:
307 307
308 count = 0; 308 count = 0;
309 CLI::callback_t fun = [&count](CLI::results_t res){ 309 CLI::callback_t fun = [&count](CLI::results_t res){
310 - count = (T) res.size(); 310 + count = static_cast<T>(res.size());
311 return true; 311 return true;
312 }; 312 };
313 313
include/CLI/TypeTools.hpp
@@ -102,7 +102,7 @@ namespace detail { @@ -102,7 +102,7 @@ namespace detail {
102 template<typename T, enable_if_t<std::is_integral<T>::value, detail::enabler> = detail::dummy> 102 template<typename T, enable_if_t<std::is_integral<T>::value, detail::enabler> = detail::dummy>
103 bool lexical_cast(std::string input, T& output) { 103 bool lexical_cast(std::string input, T& output) {
104 try{ 104 try{
105 - output = (T) std::stoll(input); 105 + output = static_cast<T>(std::stoll(input));
106 return true; 106 return true;
107 } catch (const std::invalid_argument&) { 107 } catch (const std::invalid_argument&) {
108 return false; 108 return false;
@@ -115,7 +115,7 @@ namespace detail { @@ -115,7 +115,7 @@ namespace detail {
115 template<typename T, enable_if_t<std::is_floating_point<T>::value, detail::enabler> = detail::dummy> 115 template<typename T, enable_if_t<std::is_floating_point<T>::value, detail::enabler> = detail::dummy>
116 bool lexical_cast(std::string input, T& output) { 116 bool lexical_cast(std::string input, T& output) {
117 try{ 117 try{
118 - output = (T) std::stold(input); 118 + output =static_cast<T>(std::stold(input));
119 return true; 119 return true;
120 } catch (const std::invalid_argument&) { 120 } catch (const std::invalid_argument&) {
121 return false; 121 return false;
include/CLI/Validators.hpp
@@ -81,7 +81,7 @@ std::function&lt;bool(std::string)&gt; Range(T min, T max) { @@ -81,7 +81,7 @@ std::function&lt;bool(std::string)&gt; Range(T min, T max) {
81 /// Range of one value is 0 to value 81 /// Range of one value is 0 to value
82 template<typename T> 82 template<typename T>
83 std::function<bool(std::string)> Range(T max) { 83 std::function<bool(std::string)> Range(T max) {
84 - return Range((T) 0, max); 84 + return Range(static_cast<T>(0), max);
85 } 85 }
86 86
87 /// @} 87 /// @}