aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-11 13:20:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-11 13:20:12 +0200
commit2fed3993d4f10cd6772fd4b69bd60e130436be2f (patch)
treef1f5baecee5ee74b15a81d885d73f41ae465dd7f
parentc97d5b043e21fcc26225b30b1de28f447129fdb1 (diff)
Support compilers that deduce const arrays to const reference differently
-rw-r--r--odb/pgsql/query.hxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/odb/pgsql/query.hxx b/odb/pgsql/query.hxx
index 332fc43..266e733 100644
--- a/odb/pgsql/query.hxx
+++ b/odb/pgsql/query.hxx
@@ -315,6 +315,41 @@ namespace odb
return ref_bind_typed<T, ID> (x);
}
+ // Some compilers (notably VC++), when deducing const T& from const
+ // array do not strip const from the array type. As a result, in the
+ // above signatures we get, for example, T = const char[4] instead
+ // of T = char[4], which is what we want. So to "fix" such compilers,
+ // we will have to provide the following specializations of the above
+ // functions.
+ //
+ template <typename T, std::size_t N>
+ static val_bind<T[N]>
+ _val (const T (&x) [N])
+ {
+ return val_bind<T[N]> (x);
+ }
+
+ template <database_type_id ID, typename T, std::size_t N>
+ static val_bind_typed<T[N], ID>
+ _val (const T (&x) [N])
+ {
+ return val_bind_typed<T[N], ID> (x);
+ }
+
+ template <typename T, std::size_t N>
+ static ref_bind<T[N]>
+ _ref (const T (&x) [N])
+ {
+ return ref_bind<T[N]> (x);
+ }
+
+ template <database_type_id ID, typename T, std::size_t N>
+ static ref_bind_typed<T[N], ID>
+ _ref (const T (&x) [N])
+ {
+ return ref_bind_typed<T[N], ID> (x);
+ }
+
public:
query_base&
operator+= (const query_base&);