dune-common 2.12-git
Loading...
Searching...
No Matches
container.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_COMMON_CONCEPTS_CONTAINER_HH
6#define DUNE_COMMON_CONCEPTS_CONTAINER_HH
7
8// check whether c++20 concept can be used
9#if __has_include(<version>) && __has_include(<concepts>)
10 #include <version>
11 #if __cpp_concepts >= 201907L && __cpp_lib_concepts >= 202002L
12 #ifndef DUNE_ENABLE_CONCEPTS
13 #define DUNE_ENABLE_CONCEPTS 1
14 #endif
15 #endif
16#endif
17
18#if DUNE_ENABLE_CONCEPTS
19
20#include <concepts>
21#include <iterator>
22
23namespace Dune::Concept {
24
53template<class T>
54concept Container =
57requires(T a, const T ca)
58{
59 typename T::value_type;
70 { a.max_size() } -> std::same_as<typename T::size_type>;
71 { a.empty() } -> std::convertible_to<bool>;
72};
73
95template<class T>
96concept RandomAccessContainer =
97 Container<T> &&
98requires(T a, const T ca, typename T::size_type i)
99{
106};
107
108} // end namespace Dune::Concept
109
110#endif // DUNE_ENABLE_CONCEPTS
111
112#endif // DUNE_COMMON_CONCEPTS_CONTAINER_HH
Namespace for concepts.
Definition concept.hh:33
T alignment_of_v