File indexing completed on 2024-12-29 04:50:01
0001 /* 0002 SPDX-FileCopyrightText: 2018-2023 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef KITINERARY_INTERNAL_INSTANCE_COUNTER_H 0007 #define KITINERARY_INTERNAL_INSTANCE_COUNTER_H 0008 0009 #include <QDateTime> 0010 #include <QTimeZone> 0011 0012 namespace KItinerary { 0013 0014 /** Implementation details of template code. 0015 * @internal 0016 */ 0017 namespace detail { 0018 0019 /** Compile-time instance counter. 0020 * This is based on the approach described in https://woboq.com/blog/verdigris-implementation-tricks.html 0021 * Useful for daisy-chaining overloads in the same context. 0022 */ 0023 template <int N = 255> struct num : public num<N - 1> { 0024 static constexpr int value = N; 0025 static constexpr num<N - 1> prev() { return {}; } 0026 }; 0027 template <> struct num<0> { static constexpr int value = 0; }; 0028 0029 /** type tag, to avoid unwanted overload resolution on arguments other than num<> */ 0030 template <typename T> struct tag {}; 0031 0032 } 0033 } 0034 0035 #endif