From b2f009532cd2679045a31c59eca134b2024ec83e Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 26 Sep 2022 02:01:14 +0800 Subject: [PATCH] Fixed compilation for clang on Linux --- README.md | 2 +- server/table.h | 106 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 83 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 6bb0f6c..98ae406 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ AQuery is tested on mainstream operating systems such as Windows, macOS and Linu ### Windows There're multiple options to run AQuery on Windows. You can use the native toolchain from Microsoft Visual Studio or gcc from Cygwin/MinGW or run it under Windows Subsystem for Linux. -- For WSL, Docker or linux virtual machines, see Linux, Docker sections below +- For WSL, Docker or Linux virtual machines, see Linux, Docker sections below - For Visual Studio: 1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store. 2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected. diff --git a/server/table.h b/server/table.h index 8c0e177..68cea77 100644 --- a/server/table.h +++ b/server/table.h @@ -622,86 +622,144 @@ inline void TableInfo::print(const char* __restrict sep, const char* _ std::cout << end; } } +template class VT, + class TRet> +using test_vt_support = typename std::enable_if_t, ColRef> || + std::is_same_v, ColView> || + std::is_same_v, vector_type>, TRet>; + +template class VT> +using get_autoext_type = test_vt_support::type>>; + +template class VT> +using get_long_type = test_vt_support::type>>>; + +template class VT> +using get_fp_type = test_vt_support::type>>>; + +template class VT, template class VT2, + class TRet> +using test_vt_support2 = typename std::enable_if_t<(std::is_same_v, ColRef> || + std::is_same_v, ColView> || + std::is_same_v, vector_type>) && + (std::is_same_v, ColRef> || + std::is_same_v, ColView> || + std::is_same_v, vector_type>), TRet >; +template class VT, template class VT2> +using get_autoext_type2 = test_vt_support2::type>>; + +template class VT, template class VT2> +using get_long_type2 = test_vt_support2::type>>>; + +template class VT, template class VT2> +using get_fp_type2 = test_vt_support2::type>>>; + template class VT, template class VT2> -decayed_t::type> operator -(const VT& lhs, const VT2& rhs) { - auto ret = decayed_t::type>(lhs.size); +get_autoext_type2 +operator -(const VT& lhs, const VT2& rhs) { + auto ret = get_autoext_type2(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] - rhs[i]; return ret; } template class VT> -decayed_t::type> operator -(const VT& lhs, const T2& rhs) { - auto ret = decayed_t::type>(lhs.size); +get_autoext_type +operator -(const VT& lhs, const T2& rhs) { + auto ret = get_autoext_type(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] - rhs; return ret; } template class VT> -decayed_t::type> operator -(const T2& lhs, const VT& rhs) { - auto ret = decayed_t::type>(rhs.size); +get_autoext_type +operator -(const T2& lhs, const VT& rhs) { + auto ret = get_autoext_type(rhs.size); for (uint32_t i = 0; i < rhs.size; ++i) ret[i] = lhs - rhs[i]; return ret; } template class VT, template class VT2> -decayed_t::type> operator +(const VT& lhs, const VT2& rhs) { - auto ret = decayed_t::type>(lhs.size); +get_autoext_type2 +operator +(const VT& lhs, const VT2& rhs) { + auto ret = get_autoext_type2(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] + rhs[i]; return ret; } template class VT> -decayed_t::type> operator +(const VT& lhs, const T2& rhs) { - auto ret = decayed_t::type>(lhs.size); +get_autoext_type +operator +(const VT& lhs, const T2& rhs) { + auto ret = get_autoext_type(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] + rhs; return ret; } template class VT> -decayed_t::type> operator +(const T2& lhs, const VT& rhs) { - auto ret = decayed_t::type>(rhs.size); +get_autoext_type +operator +(const T2& lhs, const VT& rhs) { + auto ret = get_autoext_type (rhs.size); for (uint32_t i = 0; i < rhs.size; ++i) ret[i] = lhs + rhs[i]; return ret; } template class VT, template class VT2> -decayed_t::type> operator *(const VT& lhs, const VT2& rhs) { - auto ret = decayed_t::type>(lhs.size); +get_long_type2 +operator *(const VT& lhs, const VT2& rhs) { + auto ret = get_long_type2(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] * rhs[i]; return ret; } template class VT> -decayed_t::type> operator *(const VT& lhs, const T2& rhs) { - auto ret = decayed_t::type>(lhs.size); +get_long_type +operator *(const VT& lhs, const T2& rhs) { + auto ret = get_long_type(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] * rhs; return ret; } template class VT> -decayed_t::type> operator *(const T2& lhs, const VT& rhs) { - auto ret = decayed_t::type>(rhs.size); +get_long_type +operator *(const T2& lhs, const VT& rhs) { + auto ret = get_long_type(rhs.size); for (uint32_t i = 0; i < rhs.size; ++i) ret[i] = lhs * rhs[i]; return ret; } template class VT, template class VT2> -decayed_t::type>> operator /(const VT& lhs, const VT2& rhs) { - auto ret = decayed_t::type>>(lhs.size); +get_fp_type2 +operator /(const VT& lhs, const VT2& rhs) { + auto ret = get_fp_type2(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] / rhs[i]; return ret; } template class VT> -decayed_t::type>> operator /(const VT& lhs, const T2& rhs) { - auto ret = decayed_t::type>>(lhs.size); +get_fp_type +operator /(const VT& lhs, const T2& rhs) { + auto ret = get_fp_type(lhs.size); for (uint32_t i = 0; i < lhs.size; ++i) ret[i] = lhs[i] / rhs; return ret; } template class VT> -decayed_t::type>> operator /(const T2& lhs, const VT& rhs) { - auto ret = decayed_t::type>>(rhs.size); +get_fp_type +operator /(const T2& lhs, const VT& rhs) { + auto ret = get_fp_type(rhs.size); for (uint32_t i = 0; i < rhs.size; ++i) ret[i] = lhs / rhs[i]; return ret;