Fix CI build errors

This commit is contained in:
yhirose
2026-02-21 08:14:47 -05:00
parent 2280f1d191
commit 9b9bda6b6e
2 changed files with 15 additions and 1 deletions
+13 -1
View File
@@ -886,7 +886,11 @@ template <typename T> T any_cast(const any &a) {
using U =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
const U *p = any_cast<U>(&a);
#ifndef CPPHTTPLIB_NO_EXCEPTIONS
if (!p) { throw bad_any_cast{}; }
#else
if (!p) { std::abort(); }
#endif
return static_cast<T>(*p);
}
@@ -894,7 +898,11 @@ template <typename T> T any_cast(any &a) {
using U =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
U *p = any_cast<U>(&a);
#ifndef CPPHTTPLIB_NO_EXCEPTIONS
if (!p) { throw bad_any_cast{}; }
#else
if (!p) { std::abort(); }
#endif
return static_cast<T>(*p);
}
@@ -902,7 +910,11 @@ template <typename T> T any_cast(any &&a) {
using U =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
U *p = any_cast<U>(&a);
#ifndef CPPHTTPLIB_NO_EXCEPTIONS
if (!p) { throw bad_any_cast{}; }
#else
if (!p) { std::abort(); }
#endif
return static_cast<T>(std::move(*p));
}
@@ -7948,7 +7960,7 @@ make_multipart_content_provider(const UploadFormDataItems &items,
if (seg.size > 0 && offset - pos < seg.size) {
size_t seg_offset = offset - pos;
size_t available = seg.size - seg_offset;
size_t to_write = std::min(available, length);
size_t to_write = (std::min)(available, length);
return sink.write(seg.data + seg_offset, to_write);
}
pos += seg.size;
+2
View File
@@ -3020,7 +3020,9 @@ TEST(AnyTest, BasicOperations) {
EXPECT_EQ(42, httplib::any_cast<int>(b));
// any_cast (value form) throws on type mismatch
#ifndef CPPHTTPLIB_NO_EXCEPTIONS
EXPECT_THROW(httplib::any_cast<std::string>(b), httplib::bad_any_cast);
#endif
// Copy
httplib::any c = b;