Skip to content

Commit b1d9099

Browse files
add std::format support
1 parent 591e05c commit b1d9099

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

orm_lib/src/SqlBinder.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include <drogon/utils/Utilities.h>
1919
#include <future>
2020
#include <regex>
21+
#if defined(__cpp_lib_format)
22+
#include <format>
23+
#endif
2124
#if USE_MYSQL
2225
#include <mysql.h>
2326
#endif
@@ -259,9 +262,14 @@ SqlBinder &SqlBinder::operator<<(double f)
259262
parameters_.push_back((char *)(obj.get()));
260263
return *this;
261264
}
265+
266+
#if defined(__cpp_lib_format)
267+
return operator<<(std::format("{:.17g}", f));
268+
#else
262269
std::stringstream ss;
263270
ss << std::setprecision(17) << f;
264271
return operator<<(ss.str());
272+
#endif
265273
}
266274

267275
SqlBinder &SqlBinder::operator<<(std::nullptr_t)

0 commit comments

Comments
 (0)