File indexing completed on 2025-01-18 10:07:23
0001
0002
0003
0004 #if 0
0005 #pragma qt_sync_skip_header_check
0006 #pragma qt_sync_stop_processing
0007 #endif
0008
0009 #ifndef QFUNCTIONALTOOLS_IMPL_H
0010 #define QFUNCTIONALTOOLS_IMPL_H
0011
0012 #include <QtCore/qtconfigmacros.h>
0013
0014 #include <type_traits>
0015 #include <utility>
0016
0017 QT_BEGIN_NAMESPACE
0018
0019 namespace QtPrivate {
0020
0021 namespace detail {
0022
0023 #define FOR_EACH_CVREF(op) \
0024 op(&) \
0025 op(const &) \
0026 op(&&) \
0027 op(const &&) \
0028
0029
0030
0031 template <typename Object, typename = void>
0032 struct StorageByValue
0033 {
0034 Object o;
0035 #define MAKE_GETTER(cvref) \
0036 constexpr Object cvref object() cvref noexcept \
0037 { return static_cast<Object cvref>(o); }
0038 FOR_EACH_CVREF(MAKE_GETTER)
0039 #undef MAKE_GETTER
0040 };
0041
0042 template <typename Object, typename Tag = void>
0043 struct StorageEmptyBaseClassOptimization : Object
0044 {
0045 StorageEmptyBaseClassOptimization() = default;
0046 StorageEmptyBaseClassOptimization(Object &&o)
0047 : Object(std::move(o))
0048 {}
0049 StorageEmptyBaseClassOptimization(const Object &o)
0050 : Object(o)
0051 {}
0052
0053 #define MAKE_GETTER(cvref) \
0054 constexpr Object cvref object() cvref noexcept \
0055 { return static_cast<Object cvref>(*this); }
0056 FOR_EACH_CVREF(MAKE_GETTER)
0057 #undef MAKE_GETTER
0058 };
0059 }
0060
0061 template <typename Object, typename Tag = void>
0062 using CompactStorage = typename std::conditional_t<
0063 std::conjunction_v<
0064 std::is_empty<Object>,
0065 std::negation<std::is_final<Object>>
0066 >,
0067 detail::StorageEmptyBaseClassOptimization<Object, Tag>,
0068 detail::StorageByValue<Object, Tag>
0069 >;
0070
0071 }
0072
0073 #undef FOR_EACH_CVREF
0074
0075 QT_END_NAMESPACE
0076
0077 #endif