From f5416f258147fa353cdd649aa56d1cc201adb2e2 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Sat, 10 Aug 2024 10:18:10 +0200 Subject: [PATCH] Remove detail::enable_if_t and move void_t to compat We have it in the compat/type_traits.h already. void_t is borrowed from c++17 --- include/sqlpp11/core/compat/type_traits.h | 30 ++++++++++++- include/sqlpp11/core/compat/utility.h | 1 + include/sqlpp11/core/detail/enable_if.h | 38 ----------------- .../core/detail/float_safe_ostringstream.h | 4 +- include/sqlpp11/core/detail/void.h | 42 ------------------- include/sqlpp11/core/result.h | 6 ++- include/sqlpp11/core/type_traits.h | 9 ++-- 7 files changed, 40 insertions(+), 90 deletions(-) delete mode 100644 include/sqlpp11/core/detail/enable_if.h delete mode 100644 include/sqlpp11/core/detail/void.h diff --git a/include/sqlpp11/core/compat/type_traits.h b/include/sqlpp11/core/compat/type_traits.h index dd660290..b58f9b4b 100644 --- a/include/sqlpp11/core/compat/type_traits.h +++ b/include/sqlpp11/core/compat/type_traits.h @@ -34,7 +34,7 @@ #define CXX_STD_VER __cplusplus #endif -#if CXX_STD_VER >= 201703L +#if CXX_STD_VER >= 201402L namespace sqlpp { using ::std::enable_if_t; @@ -49,3 +49,31 @@ namespace sqlpp } // namespace sqlpp #endif + +#if CXX_STD_VER >= 201703L +namespace sqlpp +{ + using std::void_t; +} // namespace sqlpp + +#else + +namespace sqlpp +{ + // See https://en.cppreference.com/w/cpp/types/void_t: + // "Until the resolution of CWG issue 1558 (a C++11 defect), unused parameters in alias templates were not guaranteed + // to ensure SFINAE and could be ignored [...]. + namespace detail + { + template + struct void_impl + { + using type = void; + }; + } // namespace detail + + template + using void_t = typename detail::void_impl::type; +} // namespace sqlpp + +#endif diff --git a/include/sqlpp11/core/compat/utility.h b/include/sqlpp11/core/compat/utility.h index a5e8dc4c..2724c121 100644 --- a/include/sqlpp11/core/compat/utility.h +++ b/include/sqlpp11/core/compat/utility.h @@ -49,6 +49,7 @@ namespace sqlpp namespace sqlpp { + // index_sequence & make_index_sequence template class index_sequence { diff --git a/include/sqlpp11/core/detail/enable_if.h b/include/sqlpp11/core/detail/enable_if.h deleted file mode 100644 index 8f6f9c37..00000000 --- a/include/sqlpp11/core/detail/enable_if.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -/* - * Copyright (c) 2013-2015, Roland Bock - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -namespace sqlpp -{ - namespace detail - { - template - using enable_if_t = typename std::enable_if::type; - } // namespace detail -} // namespace sqlpp diff --git a/include/sqlpp11/core/detail/float_safe_ostringstream.h b/include/sqlpp11/core/detail/float_safe_ostringstream.h index 72efa28b..36ad878a 100644 --- a/include/sqlpp11/core/detail/float_safe_ostringstream.h +++ b/include/sqlpp11/core/detail/float_safe_ostringstream.h @@ -31,7 +31,7 @@ #include #include -#include +#include namespace sqlpp { @@ -48,7 +48,7 @@ namespace sqlpp }; template - struct float_safe_ostringstream_implementation::value>> + struct float_safe_ostringstream_implementation::value>> { template void operator()(std::ostringstream& os, U&& x) const diff --git a/include/sqlpp11/core/detail/void.h b/include/sqlpp11/core/detail/void.h deleted file mode 100644 index 3b310b8f..00000000 --- a/include/sqlpp11/core/detail/void.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -/* - * Copyright (c) 2013-2015, Roland Bock - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -namespace sqlpp -{ - namespace detail - { - template - struct void_impl - { - using type = void; - }; - - template - using void_t = typename void_impl::type; - } // namespace detail -} // namespace sqlpp diff --git a/include/sqlpp11/core/result.h b/include/sqlpp11/core/result.h index 45cd33b5..0944bdbd 100644 --- a/include/sqlpp11/core/result.h +++ b/include/sqlpp11/core/result.h @@ -30,6 +30,8 @@ #include #include +#include + namespace sqlpp { template @@ -44,14 +46,14 @@ namespace sqlpp struct result_has_size : std::false_type {}; template - struct result_has_size().size())>> + struct result_has_size().size())>> : std::true_type {}; template struct result_size_type { using type = void; }; template - struct result_size_type().size())>> + struct result_size_type().size())>> { using type = decltype(std::declval().size()); }; diff --git a/include/sqlpp11/core/type_traits.h b/include/sqlpp11/core/type_traits.h index 7692c31a..6d1313d6 100644 --- a/include/sqlpp11/core/type_traits.h +++ b/include/sqlpp11/core/type_traits.h @@ -42,7 +42,6 @@ #include #include #include -#include #include namespace sqlpp @@ -522,7 +521,7 @@ namespace sqlpp using type = typename trait##_of_impl>::type; \ }; \ template \ - struct trait##_of_impl> \ + struct trait##_of_impl> \ { \ using type = typename T::_##trait; \ }; \ @@ -550,7 +549,7 @@ namespace sqlpp using type = typename trait##_impl>::type; \ }; \ template \ - struct trait##_impl> \ + struct trait##_impl> \ { \ using type = typename T::_##trait; \ }; \ @@ -746,7 +745,7 @@ namespace sqlpp }; template - struct consistency_check> + struct consistency_check> { using type = typename T::_consistency_check; }; @@ -854,7 +853,7 @@ namespace sqlpp }; template - struct serializer_context_of_impl> + struct serializer_context_of_impl> { using type = typename Db::_serializer_context_t; };