Akonadi

aktraits.h
1/*
2 SPDX-FileCopyrightText: 2019 Daniel Vrátil <dvratil@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <concepts>
10#include <utility>
11
12namespace AkTraits
13{
14/// This is a very incomplete set of Container named requirement, but I'm
15/// too lazy to implement all of them, but this should be good enough to match
16/// regular Qt containers and /not/ match arbitrary non-container types
17template<typename T>
18concept Container = requires(const T &cont) {
19 typename T::value_type;
20 typename T::iterator;
21 typename T::const_iterator;
22 typename T::size_type;
23
24 { std::begin(cont) } -> std::same_as<typename T::const_iterator>;
25 { std::end(cont) } -> std::same_as<typename T::const_iterator>;
26 { cont.size() } -> std::same_as<typename T::size_type>;
27};
28
29template<typename T>
30concept AppendableContainer = Container<T> && requires(T cont) {
31 { cont.push_back(std::declval<typename T::value_type>()) };
32};
33
34template<typename T>
35concept InsertableContainer = Container<T> && requires(T cont) {
36 { cont.insert(std::declval<typename T::iterator>(), std::declval<typename T::value_type>()) };
37};
38
39template<typename T>
40concept ReservableContainer = Container<T> && requires(T cont) {
41 { cont.reserve(std::declval<typename T::size_type>()) };
42};
43
44} // namespace AkTraits
This is a very incomplete set of Container named requirement, but I'm too lazy to implement all of th...
Definition aktraits.h:18
KGuiItem cont()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:11:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.