From 905911498dd1a3c410d0c11fea848706a63af2d8 Mon Sep 17 00:00:00 2001 From: "Jeroen T. Vermeulen" Date: Fri, 12 Feb 2021 19:44:50 +0100 Subject: [PATCH] Restrict `fill_buffer` to non-string types. Well, sort of. We don't support `char` as a C++ type that can be written to the database directly, since it's ambiguous. (Does it mean "a single character," or "a single-byte character," or "a one-byte integer," or "a one-byte _unsigned_ integer?) So, block the overload in the case where the container being passed has `char` as its content type. Such a type would presumably be meant as a string. --- include/pqxx/stream_to.hxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/pqxx/stream_to.hxx b/include/pqxx/stream_to.hxx index 02fe23b00..96ddbf564 100644 --- a/include/pqxx/stream_to.hxx +++ b/include/pqxx/stream_to.hxx @@ -213,7 +213,7 @@ public: /** This is the recommended way of inserting data. Pass your field values, * of any convertible type. */ - template void write_values(const Ts &...fields) + template void write_values(Ts const &...fields) { fill_buffer(fields...); write_buffer(); @@ -335,7 +335,9 @@ private: } /// Write raw COPY line into @c m_buffer, based on a container of fields. - template void fill_buffer(Container const &c) + template + std::enable_if_t> + fill_buffer(Container const &c) { // To avoid unnecessary allocations and deallocations, we run through c // twice: once to determine how much buffer space we may need, and once to