From 3e20fee0700cd146650bc6a5a141de3972fb1916 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Tue, 15 Feb 2022 09:19:55 +0200 Subject: [PATCH] cql3: result_set: remove std::ref from comperator& Applying std::ref on `RowComparator& cmp` hits the following compilation error on Fedora 34 with libstdc++-devel-11.2.1-9.fc34.x86_64 ``` FAILED: build/dev/cql3/statements/select_statement.o clang++ -MD -MT build/dev/cql3/statements/select_statement.o -MF build/dev/cql3/statements/select_statement.o.d -I/home/bhalevy/dev/scylla/seastar/include -I/home/bhalevy/dev/scylla/build/dev/seastar/gen/include -std=gnu++20 -U_FORTIFY_SOURCE -DSEASTAR_SSTRING -Werror=unused-result -fstack-clash-protection -DSEASTAR_API_LEVEL=6 -DSEASTAR_ENABLE_ALLOC_FAILURE_INJECTION -DSEASTAR_SCHEDULING_GROUPS_COUNT=16 -DSEASTAR_TYPE_ERASE_MORE -DFMT_LOCALE -DFMT_SHARED -I/usr/include/p11-kit-1 -DDEVEL -DSEASTAR_ENABLE_ALLOC_FAILURE_INJECTION -DSCYLLA_ENABLE_ERROR_INJECTION -O2 -DSCYLLA_ENABLE_WASMTIME -iquote. -iquote build/dev/gen --std=gnu++20 -ffile-prefix-map=/home/bhalevy/dev/scylla=. -march=westmere -DBOOST_TEST_DYN_LINK -Iabseil -fvisibility=hidden -Wall -Werror -Wno-mismatched-tags -Wno-tautological-compare -Wno-parentheses-equality -Wno-c++11-narrowing -Wno-sometimes-uninitialized -Wno-return-stack-address -Wno-missing-braces -Wno-unused-lambda-capture -Wno-overflow -Wno-noexcept-type -Wno-error=cpp -Wno-ignored-attributes -Wno-overloaded-virtual -Wno-unused-command-line-argument -Wno-defaulted-function-deleted -Wno-redeclared-class-member -Wno-unsupported-friend -Wno-unused-variable -Wno-delete-non-abstract-non-virtual-dtor -Wno-braced-scalar-init -Wno-implicit-int-float-conversion -Wno-delete-abstract-non-virtual-dtor -Wno-uninitialized-const-reference -Wno-psabi -Wno-narrowing -Wno-array-bounds -Wno-nonnull -Wno-error=deprecated-declarations -DXXH_PRIVATE_API -DSEASTAR_TESTING_MAIN -DHAVE_LZ4_COMPRESS_DEFAULT -c -o build/dev/cql3/statements/select_statement.o cql3/statements/select_statement.cc In file included from cql3/statements/select_statement.cc:14: In file included from ./cql3/statements/select_statement.hh:16: In file included from ./cql3/statements/raw/select_statement.hh:16: In file included from ./cql3/statements/raw/cf_statement.hh:16: In file included from ./cql3/cf_name.hh:16: In file included from ./cql3/keyspace_element_name.hh:16: In file included from /home/bhalevy/dev/scylla/seastar/include/seastar/core/sstring.hh:25: In file included from /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/algorithm:74: In file included from /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/pstl/glue_algorithm_defs.h:13: In file included from /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/functional:58: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/refwrap.h:319:40: error: exception specification of 'function<__gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>, void>' uses itself = decltype(reference_wrapper::_S_fun(std::declval<_Up>()))> ^ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/refwrap.h:319:40: note: in instantiation of exception specification for 'function<__gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>, void>' requested here /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/refwrap.h:321:2: note: in instantiation of default argument for 'reference_wrapper<__gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>, void>' required here reference_wrapper(_Up&& __uref) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:1017:57: note: while substituting deduced template arguments into function template 'reference_wrapper' [with _Up = __gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>, $1 = (no value), $2 = (no value)] = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; ^ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:1023:14: note: in instantiation of template type alias '__is_nothrow_constructible_impl' requested here : public __is_nothrow_constructible_impl<_Tp, _Args...>::type ^ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:153:14: note: in instantiation of template class 'std::is_nothrow_constructible<__gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>, __gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>>' requested here : public conditional<_B1::value, _B2, _B1>::type ^ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/std_function.h:298:11: note: (skipping 8 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all) return __and_>>, 131072>::iterator_type>>>, __gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>>' requested here std::__partial_sort(__first, __last, __last, __comp); ^ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:1954:9: note: in instantiation of function template specialization 'std::__introsort_loop>>, 131072>::iterator_type>>>, long, __gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>>' requested here std::__introsort_loop(__first, __last, ^ /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:4875:12: note: in instantiation of function template specialization 'std::__sort>>, 131072>::iterator_type>>>, __gnu_cxx::__ops::_Iter_comp_iter>> &, const std::vector>> &)>>>>' requested here std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); ^ ./cql3/result_set.hh:168:14: note: in instantiation of function template specialization 'std::sort>>, 131072>::iterator_type>>>, std::reference_wrapper>> &, const std::vector>> &)>>>' requested here std::sort(_rows.begin(), _rows.end(), std::ref(cmp)); ^ cql3/statements/select_statement.cc:773:21: note: in instantiation of function template specialization 'cql3::result_set::sort>> &, const std::vector>> &)>>' requested here rs->sort(_ordering_comparator); ^ 1 error generated. ninja: build stopped: subcommand failed. ``` Fixes #10079. Signed-off-by: Benny Halevy Message-Id: <20220215071955.316895-3-bhalevy@scylladb.com> --- cql3/result_set.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cql3/result_set.hh b/cql3/result_set.hh index 7e1038925e..8243fbb6ba 100644 --- a/cql3/result_set.hh +++ b/cql3/result_set.hh @@ -172,7 +172,7 @@ public: { cmp(row, row) } -> std::same_as; } void sort(const RowComparator& cmp) { - std::sort(_rows.begin(), _rows.end(), std::ref(cmp)); + std::sort(_rows.begin(), _rows.end(), cmp); } metadata& get_metadata();