diff --git a/orm_lib/inc/drogon/orm/SqlBinder.h b/orm_lib/inc/drogon/orm/SqlBinder.h index 5c286032..42dcb323 100644 --- a/orm_lib/inc/drogon/orm/SqlBinder.h +++ b/orm_lib/inc/drogon/orm/SqlBinder.h @@ -368,6 +368,21 @@ class SqlBinder : public trantor::NonCopyable std::shared_ptr obj = std::make_shared(parameter); if (type_ == ClientType::PostgreSQL) { +#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900) + const size_t size = sizeof(T); + if constexpr (size == 2) + { + *std::static_pointer_cast(obj) = htons(parameter); + } + else if constexpr (size == 4) + { + *std::static_pointer_cast(obj) = htonl(parameter); + } + else if constexpr (size == 8) + { + *std::static_pointer_cast(obj) = htonll(parameter); + } +#else switch (sizeof(T)) { case 2: @@ -385,6 +400,7 @@ class SqlBinder : public trantor::NonCopyable break; } +#endif objs_.push_back(obj); parameters_.push_back((char *)obj.get()); lengths_.push_back(sizeof(T));