Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtCore/q20chrono.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2023 Ahmad Samir <a.samirh78@gmail.com>
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef Q20CHRONO_H
0005 #define Q20CHRONO_H
0006 
0007 #include <QtCore/qtconfigmacros.h>
0008 
0009 #include <chrono>
0010 
0011 //
0012 //  W A R N I N G
0013 //  -------------
0014 //
0015 // This file is not part of the Qt API. Types and functions defined in this
0016 // file can reliably be replaced by their std counterparts, once available.
0017 // You may use these definitions in your own code, but be aware that we
0018 // will remove them once Qt depends on the C++ version that supports
0019 // them in namespace std. There will be NO deprecation warning, the
0020 // definitions will JUST go away.
0021 //
0022 // If you can't agree to these terms, don't use these definitions!
0023 //
0024 // We mean it.
0025 //
0026 
0027 QT_BEGIN_NAMESPACE
0028 
0029 namespace q20 {
0030 namespace chrono {
0031 
0032 #if defined(__GLIBCXX__)
0033 // https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/bits/chrono.h
0034 using IntRep = int64_t;
0035 #else
0036 // https://github.com/llvm/llvm-project/blob/main/libcxx/include/__chrono/duration.h
0037 // https://github.com/microsoft/STL/blob/main/stl/inc/__msvc_chrono.hpp
0038 using IntRep = int;
0039 #endif
0040 
0041 #if __cpp_lib_chrono >= 201907L
0042 using std::chrono::days;
0043 using std::chrono::weeks;
0044 using std::chrono::years;
0045 using std::chrono::months;
0046 
0047 static_assert(std::is_same_v<days::rep, IntRep>);
0048 static_assert(std::is_same_v<weeks::rep, IntRep>);
0049 static_assert(std::is_same_v<years::rep, IntRep>);
0050 static_assert(std::is_same_v<months::rep, IntRep>);
0051 #else
0052 using days = std::chrono::duration<IntRep, std::ratio<86400>>;
0053 using weeks = std::chrono::duration<IntRep, std::ratio_multiply<std::ratio<7>, days::period>>;
0054 using years = std::chrono::duration<IntRep, std::ratio_multiply<std::ratio<146097, 400>, days::period>>;
0055 using months = std::chrono::duration<IntRep, std::ratio_divide<years::period, std::ratio<12>>>;
0056 #endif // __cpp_lib_chrono >= 201907L
0057 } // namespace chrono
0058 } // namespace q20
0059 
0060 QT_END_NAMESPACE
0061 
0062 #endif /* Q20CHRONO_H */