From 5e12a12052e69c3886ca1e5426f457095c1b0e7b Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sat, 24 Feb 2024 11:06:38 +0100 Subject: [PATCH 1/2] make GetSemantic() constexpr --- ebml/EbmlElement.h | 9 ++++++++- src/EbmlMaster.cpp | 12 ------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index a5c20120..94410708 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -17,6 +17,7 @@ #include #include #include +#include namespace libebml { @@ -526,7 +527,13 @@ class EBML_DLL_API EbmlSemanticContextMaster : public EbmlSemanticContext { return false; } - const EbmlSemantic & GetSemantic(std::size_t i) const; + inline constexpr const EbmlSemantic & GetSemantic(std::size_t i) const + { + if (i= " << GetSize() << ")"; - throw std::logic_error(ss.str()); -} - - /*! \todo handle exception on errors \todo write all the Mandatory elements in the Context, otherwise assert From cd9959582d1fec646b398a21a8b7f6dae1e50ded Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sat, 24 Feb 2024 11:09:05 +0100 Subject: [PATCH 2/2] make EBML_CTX_IDX return a constexpr --- ebml/EbmlElement.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index 94410708..4648dce0 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -539,7 +539,7 @@ class EBML_DLL_API EbmlSemanticContextMaster : public EbmlSemanticContext { const EbmlSemantic *MyTable; ///< First element in the table }; -static inline const EbmlSemantic & tEBML_CTX_IDX(const EbmlSemanticContextMaster & c, std::size_t i) +static inline constexpr const EbmlSemantic & tEBML_CTX_IDX(const EbmlSemanticContextMaster & c, std::size_t i) { return c.GetSemantic(i); }