From 6b66127691dbd288cf8cc6ba4cfe71c95a7f0d4d Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 14 Feb 2019 05:15:53 +0000 Subject: [PATCH] [ox/std] Add missing constexprs to BString methods --- deps/ox/src/ox/std/string.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index 240bd91af..efb403e28 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -50,17 +50,17 @@ class BString { /** * Returns the number of characters in this string. */ - std::size_t len() const noexcept; + constexpr std::size_t len() const noexcept; /** * Returns the number of bytes used for this string. */ - std::size_t bytes() const noexcept; + constexpr std::size_t bytes() const noexcept; /** * Returns the capacity of bytes for this string. */ - std::size_t cap() const noexcept; + constexpr std::size_t cap() const noexcept; }; template @@ -158,7 +158,7 @@ constexpr const char *BString::c_str() const noexcept { template -std::size_t BString::len() const noexcept { +constexpr std::size_t BString::len() const noexcept { std::size_t length = 0; for (std::size_t i = 0; i < buffLen; i++) { uint8_t b = m_buff[i]; @@ -176,14 +176,14 @@ std::size_t BString::len() const noexcept { } template -std::size_t BString::bytes() const noexcept { - std::size_t i; +constexpr std::size_t BString::bytes() const noexcept { + std::size_t i = 0; for (i = 0; i < buffLen && m_buff[i]; i++); return i + 1; // add one for null terminator } template -std::size_t BString::cap() const noexcept { +constexpr std::size_t BString::cap() const noexcept { return buffLen; }