From 5978ca071d0061a9c7ea130ccdbbde7417b49259 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 20 Jun 2020 03:49:38 -0500 Subject: [PATCH] [ox/std] Make String comparison operators const correct (synced from a9ec6351607b21eca46129515814746e561152d1) --- src/ox/std/string.cpp | 4 ++-- src/ox/std/string.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ox/std/string.cpp b/src/ox/std/string.cpp index 18d1b9bbe..ba1342ed1 100644 --- a/src/ox/std/string.cpp +++ b/src/ox/std/string.cpp @@ -125,7 +125,7 @@ const String String::operator+(const String &src) const noexcept { return *this + src.c_str(); } -bool String::operator==(const String &other) noexcept { +bool String::operator==(const String &other) const noexcept { bool retval = true; std::size_t i = 0; while (i < m_buff.size() && (m_buff[i] || other.m_buff[i])) { @@ -138,7 +138,7 @@ bool String::operator==(const String &other) noexcept { return retval; } -bool String::operator!=(const String &other) noexcept { +bool String::operator!=(const String &other) const noexcept { return !operator==(other); } diff --git a/src/ox/std/string.hpp b/src/ox/std/string.hpp index 67b468e5f..46568cc9e 100644 --- a/src/ox/std/string.hpp +++ b/src/ox/std/string.hpp @@ -59,9 +59,9 @@ class String { const String operator+(const String &src) const noexcept; - bool operator==(const String &other) noexcept; + bool operator==(const String &other) const noexcept; - bool operator!=(const String &other) noexcept; + bool operator!=(const String &other) const noexcept; char operator[](std::size_t i) const noexcept;