Skip to content

Commit 8d8ae3e

Browse files
authored
Use cascading ternary operators for C++11 mode
The comparison function is using C++14 constexpr, which is fine when we decide to move to C++14. In the meantime, let's support C++11 users.
1 parent 14511e9 commit 8d8ae3e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

include/network/string_view.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,8 @@ class basic_string_view {
161161
}
162162

163163
constexpr int compare(basic_string_view s) const noexcept {
164-
if (size() != s.size())
165-
return size() < s.size() ? -1 : 1;
166-
return traits::compare(data(), s.data(), size());
164+
return (size() != s.size()) ? (size() < s.size()) ? -1 : 1
165+
: traits::compare(data(), s.data(), size());
167166
}
168167

169168
constexpr int compare(size_type pos1, size_type n1,

0 commit comments

Comments
 (0)