Skip to content

Commit af4aaea

Browse files
committed
Use string::npos to check if substring was found
Instead of checking for the value -1 directly, use string::npos to determine when calls to string::find did not find the target substring. This also fixes a compiler warning about comparing an unsigned variable to a signed value.
1 parent c98a475 commit af4aaea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/cppflow/model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace cppflow {
143143

144144
inline std::tuple<std::string, int> parse_name(const std::string& name) {
145145
auto idx = name.find(':');
146-
return (idx == -1 ? std::make_tuple(name, 0) : std::make_tuple(name.substr(0, idx), std::stoi(name.substr(idx + 1))));
146+
return (idx == std::string::npos ? std::make_tuple(name, 0) : std::make_tuple(name.substr(0, idx), std::stoi(name.substr(idx + 1))));
147147
}
148148

149149
inline std::vector<tensor> model::operator()(std::vector<std::tuple<std::string, tensor>> inputs, std::vector<std::string> outputs) {

0 commit comments

Comments
 (0)