diff --git a/toml/get.hpp b/toml/get.hpp index fbecd60..3af7ea8 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -825,107 +825,6 @@ find_or(const basic_value& v, const toml::key& ky, T&& opt) return get_or(tab.at(ky), std::forward(opt)); } -// =========================================================================== -// find_or(table, key, opt) - -// --------------------------------------------------------------------------- -// exact types (return type can be a reference) -template -detail::enable_if_t, detail::is_basic_value, - detail::is_exact_toml_type - >::value, T> const& -find_or(const Table& tab, const key& ky, const T& opt) -{ - if(tab.count(ky) == 0) {return opt;} - return get_or(tab.at(ky), opt); -} - -template -detail::enable_if_t, detail::is_basic_value, - detail::is_exact_toml_type - >::value, T>& -find_or(Table& tab, const key& ky, T& opt) -{ - if(tab.count(ky) == 0) {return opt;} - return get_or(tab[ky], opt); -} - -template -detail::enable_if_t, detail::is_basic_value, - detail::is_exact_toml_type - >::value, T>&& -find_or(typename std::remove_reference::type&& tab, const key& ky, T&& opt) -{ - if(tab.count(ky) == 0) {return opt;} - return get_or(std::move(tab[ky]), std::forward(opt)); -} - -// --------------------------------------------------------------------------- -// std::string (return type can be a reference) -template -detail::enable_if_t, detail::is_basic_value, - std::is_same - >::value, std::string> const& -find_or(const Table& tab, const key& ky, const T& opt) -{ - if(tab.count(ky) == 0) {return opt;} - return get_or(tab.at(ky), opt); -} -template -detail::enable_if_t, detail::is_basic_value, - std::is_same - >::value, std::string>& -find_or(Table& tab, const key& ky, T& opt) -{ - if(tab.count(ky) == 0) {return opt;} - return get_or(tab[ky], opt); -} -template -detail::enable_if_t, detail::is_basic_value, - std::is_same - >::value, std::string> -find_or(Table&& tab, const key& ky, T&& opt) -{ - if(tab.count(ky) == 0) {return std::forward(opt);} - return get_or(std::move(tab[ky]), std::forward(opt)); -} - -// --------------------------------------------------------------------------- -// string literal (deduced as std::string) -template -detail::enable_if_t, - detail::is_basic_value, - detail::is_string_literal::type> - >::value, std::string> -find_or(const Table& tab, const key& ky, T&& opt) -{ - if(tab.count(ky) == 0) {return std::string(opt);} - return get_or(tab.at(ky), std::forward(opt)); -} - -// --------------------------------------------------------------------------- -// others (require type conversion and return type cannot be lvalue reference) -template -detail::enable_if_t, - detail::is_basic_value, - detail::negation>, - detail::negation>, - detail::negation::type>> - >::value, T> -find_or(const Table& tab, const key& ky, T&& opt) -{ - if(tab.count(ky) == 0) {return opt;} - return get_or(tab.at(ky), std::forward(opt)); -} - // ============================================================================ // expect