summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-07-29 13:48:03 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-07-29 13:48:03 +0100
commitdf3b30e6db47f0c43ebef55a4d0d268c8c80dedc (patch)
tree2296952383adac8ce5ca3df80638595d55aae8b4
parentUse faster std::from_chars over boost::lexical_cast if possible (diff)
downloadicespider-df3b30e6db47f0c43ebef55a4d0d268c8c80dedc.tar.bz2
icespider-df3b30e6db47f0c43ebef55a4d0d268c8c80dedc.tar.xz
icespider-df3b30e6db47f0c43ebef55a4d0d268c8c80dedc.zip
Use std::to_string in setCooke if possible
-rw-r--r--icespider/core/ihttpRequest.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h
index 6cce145..99de25a 100644
--- a/icespider/core/ihttpRequest.h
+++ b/icespider/core/ihttpRequest.h
@@ -135,12 +135,14 @@ namespace IceSpider {
setCookie(const std::string_view n, const T & v, const OptionalString & d, const OptionalString & p, bool s,
std::optional<time_t> e)
{
- if constexpr (std::is_constructible<std::string_view, T>::value) {
+ if constexpr (std::is_constructible_v<std::string_view, T>) {
setCookie(n, std::string_view(v), d, p, s, e);
}
+ else if constexpr (requires { std::to_string(v); }) {
+ setCookie(n, std::to_string(v), d, p, s, e);
+ }
else {
- auto vs = boost::lexical_cast<std::string>(v);
- setCookie(n, std::string_view(vs), d, p, s, e);
+ setCookie(n, boost::lexical_cast<std::string>(v), d, p, s, e);
}
}