From d73bc6076c5d1b914e955075d511ab8bc749ee65 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sat, 28 Sep 2019 16:16:44 +0900 Subject: [PATCH] feat: add basic_value::at(key) and at(idx) --- toml/value.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/toml/value.hpp b/toml/value.hpp index 3d24c83..cdb9506 100644 --- a/toml/value.hpp +++ b/toml/value.hpp @@ -1567,6 +1567,28 @@ class basic_value return std::move(this->table_.value()); } + // accessors ============================================================= + // + // may throw type_error or out_of_range + // + value_type& at(const key& k) + { + return this->as_table().at(k); + } + value_type const& at(const key& k) const + { + return this->as_table().at(k); + } + + value_type& at(const std::size_t idx) + { + return this->as_array().at(idx); + } + value_type const& at(const std::size_t idx) const + { + return this->as_array().at(idx); + } + source_location location() const { return source_location(this->region_info_.get());