diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-07-29 11:20:07 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-07-29 11:22:07 +0100 |
commit | de523833e3b27b1a83777c461a1b4fbdd70c0689 (patch) | |
tree | e71cb6b624e018cb5288d90f40e7cdf699f5a9bd | |
parent | Rename internal paramGet functions to disambiguate from the typed ones (diff) | |
download | icespider-de523833e3b27b1a83777c461a1b4fbdd70c0689.tar.bz2 icespider-de523833e3b27b1a83777c461a1b4fbdd70c0689.tar.xz icespider-de523833e3b27b1a83777c461a1b4fbdd70c0689.zip |
Don't need a specific handler for string_view->string
-rw-r--r-- | icespider/core/ihttpRequest.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h index 5141068..e226e42 100644 --- a/icespider/core/ihttpRequest.h +++ b/icespider/core/ihttpRequest.h @@ -59,6 +59,8 @@ namespace IceSpider { virtual std::ostream & dump(std::ostream & s) const = 0; + static_assert(std::is_constructible_v<std::string, std::string_view>); + template<typename T, typename K> [[nodiscard]] inline std::optional<T> getFrom(const K & key, OptionalString (IHttpRequest::*src)(const K &) const) const @@ -67,12 +69,9 @@ namespace IceSpider { if constexpr (std::is_convertible<std::string_view, T>::value) { return *v; } - else if constexpr (std::is_constructible<std::string_view, T>::value) { + else if constexpr (std::is_constructible<T, std::string_view>::value) { return T(*v); } - else if constexpr (std::is_same<std::string, T>::value) { - return std::to_string(*v); - } else { try { return boost::lexical_cast<T>(*v); |