From 8d8ae3e94f90d3a7c86f48b9ac31732eed40af81 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 15 Jun 2018 09:17:57 +1000 Subject: [PATCH] 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. --- include/network/string_view.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/network/string_view.hpp b/include/network/string_view.hpp index d5d83fd9..8da6daab 100644 --- a/include/network/string_view.hpp +++ b/include/network/string_view.hpp @@ -161,9 +161,8 @@ class basic_string_view { } constexpr int compare(basic_string_view s) const noexcept { - if (size() != s.size()) - return size() < s.size() ? -1 : 1; - return traits::compare(data(), s.data(), size()); + return (size() != s.size()) ? (size() < s.size()) ? -1 : 1 + : traits::compare(data(), s.data(), size()); } constexpr int compare(size_type pos1, size_type n1,