diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 14:06:08 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-08-15 14:43:30 +0200 |
commit | 3ef8ec2ee187b949b3f6840ca03bcc0e814c00a9 (patch) | |
tree | 2d9794d1b2ec0ec1caa8f8da3bf6ddc32fb9d894 /src/corelib/global | |
parent | 8ad9e81694fda39fbecebb9f97491004e9ac8c41 (diff) |
Constrain the data stream operators for containers
Check that we can successfully instantiate the data
stream operator for a container before we actually try.
This is required so we can automate registration of debug
stream operators with QMetaType.
Change-Id: Ib100a5242470d7fc8067058cc4d81af2fa9354b0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 2f7bb414b5..e45347ee10 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -464,6 +464,17 @@ struct has_ostream_operator<Stream, T, std::void_t<decltype(detail::reference<St template <typename Stream, typename T> constexpr bool has_ostream_operator_v = has_ostream_operator<Stream, T>::value; +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 {}; +template <typename Stream, typename T> +constexpr bool has_istream_operator_v = has_istream_operator<Stream, T>::value; + +template <typename Stream, typename T> +constexpr bool has_stream_operator_v = has_ostream_operator_v<Stream, T> && has_istream_operator_v<Stream, T>; + } |