summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-04-30 15:16:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-04-30 15:16:33 +0200
commitb3ec2267f7ec7a4f590856f8de82eaf7af3de5fb (patch)
tree679920e10ffc70c23b8a0b9b7e2311235fcb5c98
parentf9cda8a43f7ef65a75a84e0c2a11241916d25250 (diff)
Use decay_traits in dynamic query support to handle array decay
-rw-r--r--libodb/odb/query-dynamic.hxx22
-rw-r--r--odb-tests/common/query/array/driver.cxx20
2 files changed, 12 insertions, 30 deletions
diff --git a/libodb/odb/query-dynamic.hxx b/libodb/odb/query-dynamic.hxx
index cd0ce05..8c4edae 100644
--- a/libodb/odb/query-dynamic.hxx
+++ b/libodb/odb/query-dynamic.hxx
@@ -361,10 +361,6 @@ namespace odb
void* param_factory;
};
- template <typename T>
- const T&
- type_instance ();
-
// This class template has to remain POD since we rely on it being
// 0-initialized before any dynamic initialization takes place in
// any other translation unit.
@@ -892,7 +888,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () == type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () ==
+ decay_traits<T2>::instance ()));
query_base q (native_info);
q.append (c.native_info);
@@ -906,7 +903,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () != type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () !=
+ decay_traits<T2>::instance ()));
query_base q (native_info);
q.append (c.native_info);
@@ -920,7 +918,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () < type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () <
+ decay_traits<T2>::instance ()));
query_base q (native_info);
q.append (c.native_info);
@@ -934,7 +933,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () > type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () >
+ decay_traits<T2>::instance ()));
query_base q (native_info);
q.append (c.native_info);
@@ -948,7 +948,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () <= type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () <=
+ decay_traits<T2>::instance ()));
query_base q (native_info);
q.append (c.native_info);
@@ -962,7 +963,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () >= type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () >=
+ decay_traits<T2>::instance ()));
query_base q (native_info);
q.append (c.native_info);
diff --git a/odb-tests/common/query/array/driver.cxx b/odb-tests/common/query/array/driver.cxx
index 9327751..43d91f2 100644
--- a/odb-tests/common/query/array/driver.cxx
+++ b/odb-tests/common/query/array/driver.cxx
@@ -143,27 +143,7 @@ main (int argc, char* argv[])
assert (size (db->query<object> ("s = " + query::_ref (s))) == 1);
#endif
- // @@ BUILD2 Ends up with the following warning, but strangely only in the
- // multi-database mode:
- //
- // In file included from odb/odb-tests/common/query/array/test-odb.hxx:31,
- // from odb/odb-tests/common/query/array/driver.cxx:20:
- // odb/libodb/odb/query-dynamic.hxx: In instantiation of ‘odb::query_base odb::query_column<T>::operator==(const odb::query_column<T2>&) const [with T2 = char [17]; T = char [17]]’:
- // odb/odb-tests/common/query/array/driver.cxx:144:7: required from here
- // odb/libodb/odb/query-dynamic.hxx:895:43: error: comparison between two arrays is deprecated in C++20 [-Werror=array-compare]
- // 895 | (void) (sizeof (type_instance<T> () == type_instance<T2> ()));
- // | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
- // odb/libodb/odb/query-dynamic.hxx:895:43: note: use unary ‘+’ which decays operands to pointers or ‘&‘indirect_ref’ not supported by dump_decl<declaration error>[0] == &‘indirect_ref’ not supported by dump_decl<declaration error>[0]’ to compare the addresses
- //
- // Looks like compile-time assertion. Doesn't make much sense for
- // arrays since compares pointers to objects rather than objects.
- // Should we somehow suppress the assertion for arrays or similar?
- //
- // Note: temporarily ifndef-ed.
- //
-#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == query::s1)) == 3);
-#endif
// std::array
//