From 659830fcdf7c8834c81a90679e1daba604dd00b3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 18 Apr 2021 15:07:51 -0500 Subject: [PATCH] [ox/model] Improve const correctness of SerStr and UnionView --- deps/ox/src/ox/model/types.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/deps/ox/src/ox/model/types.hpp b/deps/ox/src/ox/model/types.hpp index f285aa6e..626b97de 100644 --- a/deps/ox/src/ox/model/types.hpp +++ b/deps/ox/src/ox/model/types.hpp @@ -46,7 +46,7 @@ class SerStr { m_cap = cap; } - constexpr const char *c_str() noexcept { + constexpr const char *c_str() const noexcept { return m_str; } @@ -59,11 +59,11 @@ class SerStr { return m_str; } - constexpr int len() noexcept { + constexpr int len() const noexcept { return static_cast(m_str ? ox_strlen(m_str) : 0); } - constexpr int cap() noexcept { + constexpr int cap() const noexcept { return m_cap; } @@ -77,13 +77,17 @@ class UnionView { typename enable_if, Union>::type *m_union = nullptr; public: - constexpr explicit UnionView(Union *u, int idx) noexcept: m_idx(idx), m_union(u) { + constexpr UnionView(Union *u, int idx) noexcept: m_idx(idx), m_union(u) { } - constexpr auto idx() noexcept { + constexpr auto idx() const noexcept { return m_idx; } + constexpr const Union *get() const noexcept { + return m_union; + } + constexpr Union *get() noexcept { return m_union; }