Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dutils_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DUTILS_P_H
7#define QQUICK3DUTILS_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <type_traits>
21
22#include <QtCore/QtGlobal>
23#include <private/qglobal_p.h>
24
25QT_BEGIN_NAMESPACE
26
27template <typename T, typename = void>
28struct hasFuzzyCompare : std::false_type {};
29
30template <typename T>
31struct hasFuzzyCompare<T, std::void_t<decltype(qFuzzyCompare(std::declval<T &>(), std::declval<T &>()))>> : std::true_type {};
32
33// Assigns 'updated' to 'orig' and returns true if they are different
34template <typename T, std::enable_if_t<!hasFuzzyCompare<T>::value, bool> = true>
35bool qUpdateIfNeeded(T &orig, T updated)
36{
37 if (orig == updated)
38 return false;
39 orig = updated;
40 return true;
41}
42
43// Assigns 'updated' to 'orig' and returns true if they are different, compared with qFuzzyCompare
44template <typename T, std::enable_if_t<hasFuzzyCompare<T>::value, bool> = true>
45bool qUpdateIfNeeded(T &orig, T updated)
46{
47 if (qFuzzyCompare(orig, updated))
48 return false;
49 orig = updated;
50 return true;
51}
52
53QT_END_NAMESPACE
54
55#endif // QQUICK3DUTILS_P_H
Combined button and popup list for selecting options.
bool qUpdateIfNeeded(T &orig, T updated)