From bfa5700df00e72c752472e6c26a8739c52cf51fb Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 1 Apr 2018 14:44:15 +1000 Subject: [PATCH] view: add string comparison operators --- view.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/view.hpp b/view.hpp index 9438cfc7..9e2240e0 100644 --- a/view.hpp +++ b/view.hpp @@ -684,6 +684,24 @@ namespace util { } + /////////////////////////////////////////////////////////////////////////// + template + bool + operator== ( + util::view lhs, + const std::basic_string &rhs + ) { + return lhs.size () == rhs.size () && std::equal (lhs.cbegin (), lhs.cend (), rhs.cbegin ()); + } + + + inline bool + operator== (util::view lhs, const char *rhs) + { + return lhs.size () == strlen (rhs) && std::equal (lhs.cbegin (), lhs.cend (), rhs); + } + + /////////////////////////////////////////////////////////////////////////// template std::ostream&