// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #if 0 #pragma qt_sync_skip_header_check #pragma qt_sync_stop_processing #endif #ifndef QFUNCTIONALTOOLS_IMPL_H #define QFUNCTIONALTOOLS_IMPL_H #include #include #include QT_BEGIN_NAMESPACE namespace QtPrivate { namespace detail { #define FOR_EACH_CVREF(op) \ op(&) \ op(const &) \ op(&&) \ op(const &&) \ /* end */ template struct StorageByValue { Object o; #define MAKE_GETTER(cvref) \ constexpr Object cvref object() cvref noexcept \ { return static_cast(o); } FOR_EACH_CVREF(MAKE_GETTER) #undef MAKE_GETTER }; template struct StorageEmptyBaseClassOptimization : Object { StorageEmptyBaseClassOptimization() = default; StorageEmptyBaseClassOptimization(Object &&o) : Object(std::move(o)) {} StorageEmptyBaseClassOptimization(const Object &o) : Object(o) {} #define MAKE_GETTER(cvref) \ constexpr Object cvref object() cvref noexcept \ { return static_cast(*this); } FOR_EACH_CVREF(MAKE_GETTER) #undef MAKE_GETTER }; } // namespace detail template using CompactStorage = typename std::conditional_t< std::conjunction_v< std::is_empty, std::negation> >, detail::StorageEmptyBaseClassOptimization, detail::StorageByValue >; } // namespace QtPrivate #undef FOR_EACH_CVREF QT_END_NAMESPACE #endif // QFUNCTIONALTOOLS_IMPL_H