diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-10-15 16:30:31 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-03-05 15:30:05 +0100 |
commit | 6de9acf7793a299322923b3ac02142a5e5998842 (patch) | |
tree | fbaba04169cd7a93642362add671c10fd0d1bac6 | |
parent | 684d44024f71b66994687d632cde5b10c92e6d21 (diff) |
qtypeinfo: make variable templates inline
And refactor the TMP to use std::conjunction and use variable template
specialization instead of template class specialization for the base
cases.
Change-Id: Iea6a03f13ea3443a0fa7365af21c496670c1e07f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index e5914414f2..fea6ecd45c 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -311,14 +311,13 @@ struct expand_operator_less_than_tuple<std::variant<T...>> : expand_operator_les } template<typename T, typename = void> -struct is_dereferenceable : std::false_type {}; +inline constexpr bool is_dereferenceable_v = false; template<typename T> -struct is_dereferenceable<T, std::void_t<decltype(std::declval<T>().operator->())> > - : std::true_type {}; +inline constexpr bool is_dereferenceable_v<T, std::void_t<decltype(std::declval<T>().operator->())> > = true; template <typename T> -inline constexpr bool is_dereferenceable_v = is_dereferenceable<T>::value; +using is_dereferenceable = std::bool_constant<is_dereferenceable_v<T>>; template<typename T> struct has_operator_equal : detail::expand_operator_equal<T> {}; @@ -345,25 +344,31 @@ T &reference(); } -template <typename Stream, typename, typename = void> -struct has_ostream_operator : std::false_type {}; +template <typename Stream, typename T, typename = void> +inline constexpr bool has_ostream_operator_v = false; + template <typename Stream, typename T> -struct has_ostream_operator<Stream, T, std::void_t<decltype(detail::reference<Stream>() << detail::const_reference<T>())>> - : std::true_type {}; +inline constexpr bool has_ostream_operator_v<Stream, T, std::void_t<decltype(detail::reference<Stream>() << detail::const_reference<T>())>> = true; + template <typename Stream, typename T> -inline constexpr bool has_ostream_operator_v = has_ostream_operator<Stream, T>::value; +using has_ostream_operator = std::bool_constant<has_ostream_operator_v<Stream, T>>; + + + +template <typename Stream, typename T, typename = void> +inline constexpr bool has_istream_operator_v = false; -template <typename Stream, typename, typename = void> -struct has_istream_operator : std::false_type {}; template <typename Stream, typename T> -struct has_istream_operator<Stream, T, std::void_t<decltype(detail::reference<Stream>() >> detail::reference<T>())>> - : std::true_type {}; +inline constexpr bool has_istream_operator_v<Stream, T, std::void_t<decltype(detail::reference<Stream>() >> detail::reference<T>())>> = true; + template <typename Stream, typename T> -inline constexpr bool has_istream_operator_v = has_istream_operator<Stream, T>::value; +using has_istream_operator = std::bool_constant<has_istream_operator_v<Stream, T>>; template <typename Stream, typename T> inline constexpr bool has_stream_operator_v = has_ostream_operator_v<Stream, T> && has_istream_operator_v<Stream, T>; +template <typename Stream, typename T> +using has_stream_operator = std::conjunction<has_ostream_operator<Stream, T>, has_istream_operator<Stream, T>>; } |