From a1095f3e4c2d05aa95387efd04632cae0daec7e4 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sat, 28 Sep 2019 11:03:14 +0900 Subject: [PATCH] refactor: use std::map::at instead of [] --- toml/get.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toml/get.hpp b/toml/get.hpp index 9278cbf..829ef76 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -768,7 +768,7 @@ find_or(basic_value& v, const toml::key& ky, basic_value& opt) if(!v.is_table()) {return opt;} auto& tab = v.as_table(); if(tab.count(ky) == 0) {return opt;} - return tab[ky]; + return tab.at(ky); } template&& v, const toml::key& ky, basic_value&& op if(!v.is_table()) {return opt;} auto tab = std::move(v).as_table(); if(tab.count(ky) == 0) {return opt;} - return std::move(tab[ky]); + return std::move(tab.at(ky)); } // --------------------------------------------------------------------------- @@ -805,7 +805,7 @@ find_or(basic_value& v, const toml::key& ky, T& opt) if(!v.is_table()) {return opt;} auto& tab = v.as_table(); if(tab.count(ky) == 0) {return opt;} - return get_or(tab[ky], opt); + return get_or(tab.at(ky), opt); } template&& v, const toml::key& ky, T&& opt) if(!v.is_table()) {return opt;} auto tab = std::move(v).as_table(); if(tab.count(ky) == 0) {return opt;} - return get_or(std::move(tab[ky]), std::forward(opt)); + return get_or(std::move(tab.at(ky)), std::forward(opt)); } // ---------------------------------------------------------------------------