Dune Core Modules (unstable)

hashable.hh
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_HASHABLE_HH
6#define DUNE_COMMON_CONCEPTS_HASHABLE_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 <cstddef>
22#include <functional>
23
24namespace Dune::Concept {
25
47template<class T>
48concept Hashable = requires(T a)
49{
50 { std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
51};
52
53} // end namespace Dune::Concept
54
55#endif // DUNE_ENABLE_CONCEPTS
56
57#endif // DUNE_COMMON_CONCEPTS_HASHABLE_HH
Namespace for concepts.
Definition: concept.hh:34
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)