From 074e3507aa5179bd6e1af8242f3e4d7431efe245 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Thu, 30 Jan 2025 00:13:10 +0900 Subject: [PATCH] feat: consider type check is also `access` --- include/toml11/value.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/toml11/value.hpp b/include/toml11/value.hpp index 85c2643..3c4729d 100644 --- a/include/toml11/value.hpp +++ b/include/toml11/value.hpp @@ -1342,9 +1342,13 @@ class basic_value std::nullptr_t> = nullptr> bool is() const noexcept { - return detail::type_to_enum::value == this->type_; + return this->is(detail::type_to_enum::value); + } + bool is(value_t t) const noexcept + { + this->set_accessed(); + return t == this->type_; } - bool is(value_t t) const noexcept {return t == this->type_;} bool is_empty() const noexcept {return this->is(value_t::empty );} bool is_boolean() const noexcept {return this->is(value_t::boolean );} @@ -1360,6 +1364,7 @@ class basic_value bool is_array_of_tables() const noexcept { + this->set_accessed(); if( ! this->is_array()) {return false;} const auto& a = this->as_array(std::nothrow); // already checked. @@ -1379,7 +1384,11 @@ class basic_value return true; } - value_t type() const noexcept {return type_;} + value_t type() const noexcept + { + this->set_accessed(); + return type_; + } // }}}