| 1 | // Copyright (C) 2025 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QMULTIMEDIA_RANGES_P_H |
| 5 | #define QMULTIMEDIA_RANGES_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/qtconfigmacros.h> |
| 19 | |
| 20 | #ifdef __cpp_lib_ranges |
| 21 | # include <ranges> // IWYU pragma: export |
| 22 | #endif |
| 23 | |
| 24 | #include <algorithm> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | namespace QtMultimediaPrivate::ranges { |
| 29 | |
| 30 | #ifdef __cpp_lib_ranges |
| 31 | using std::ranges::equal; |
| 32 | using std::ranges::fill; |
| 33 | |
| 34 | #else |
| 35 | |
| 36 | // Caveat: best effort, not a 1-to-1 mapping to c++20 style ranges |
| 37 | |
| 38 | constexpr auto equal = [](const auto &lhs, const auto &rhs, auto &&predicate) { |
| 39 | return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), predicate); |
| 40 | }; |
| 41 | |
| 42 | constexpr auto fill = [](auto &range, auto &&value) { |
| 43 | return std::fill(std::begin(range), std::end(range), value); |
| 44 | }; |
| 45 | |
| 46 | #endif |
| 47 | |
| 48 | } // namespace QtMultimediaPrivate::ranges |
| 49 | |
| 50 | QT_END_NAMESPACE |
| 51 | |
| 52 | #endif // QMULTIMEDIA_RANGES_P_H |
| 53 | |
| 54 | |