From 15b68a89c6a291110bc916c5412b2943514f706a Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sat, 31 Aug 2019 13:04:25 +0900 Subject: [PATCH] fix: suppress warnings by forwarding argument --- toml/get.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/toml/get.hpp b/toml/get.hpp index 61e2d07..07b4b27 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -863,7 +863,7 @@ detail::enable_if_t< std::string> find_or(const basic_value& v, const toml::key& ky, T&& opt) { - if(!v.is_table()) {return opt;} + if(!v.is_table()) {return std::string(opt);} const auto& tab = v.as_table(); if(tab.count(ky) == 0) {return std::string(opt);} return get_or(tab.at(ky), std::forward(opt)); @@ -874,19 +874,22 @@ find_or(const basic_value& v, const toml::key& ky, T&& opt) template class M, template class V> detail::enable_if_t::type>::type, basic_value>>, + // T is not std::string detail::negation::type>::type>>, + // T is not a string literal detail::negation::type>> - >::value, T> + >::value, typename std::remove_cv::type>::type> find_or(const basic_value& v, const toml::key& ky, T&& opt) { - if(!v.is_table()) {return opt;} + if(!v.is_table()) {return std::forward(opt);} const auto& tab = v.as_table(); - if(tab.count(ky) == 0) {return opt;} + if(tab.count(ky) == 0) {return std::forward(opt);} return get_or(tab.at(ky), std::forward(opt)); }