ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
CxxUtils
CxxUtils
concepts.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
/*
3
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
4
*/
11
12
13
#ifndef CXXUTILS_CONCEPTS_H
14
#define CXXUTILS_CONCEPTS_H
15
16
17
#include <type_traits>
18
#include <iterator>
19
#include <concepts>
20
21
22
// Some library concepts.
23
24
namespace
CxxUtils
{
25
namespace
detail
{
26
27
28
// Standard library Hash requirement.
29
template
<
class
HASHER,
class
T>
30
concept
IsHash
=
31
std::destructible<HASHER> &&
32
std::copy_constructible<HASHER> &&
33
requires
(
const
HASHER&
h
, T
x
)
34
{
35
{
h
(
x
) } -> std::same_as<std::size_t>;
36
};
37
38
39
// Standard library BinaryPredicate requirement.
40
template
<
class
PRED,
class
ARG1,
class
ARG2=ARG1>
41
concept
IsBinaryPredicate
=
42
std::copy_constructible<PRED> &&
43
std::predicate<PRED, ARG1, ARG2>;
44
45
46
template
<
class
CONTAINER>
47
concept
IsContiguousContainer
=
48
requires
(CONTAINER& c)
49
{
50
requires
std::contiguous_iterator<
decltype
(c.begin())>;
51
};
52
53
54
template
<
class
ITERATOR,
class
VAL>
55
concept
InputValIterator
=
56
std::input_iterator<ITERATOR> &&
57
std::convertible_to<std::iter_value_t<ITERATOR>, VAL>;
58
59
template
<
typename
SET>
60
concept
SimpleAssociativeContainer
=
requires
(
SET
s,
typename
SET::key_type k) {
61
typename
SET::value_type;
62
typename
SET::key_type;
63
typename
SET::iterator;
64
typename
SET::const_iterator;
65
typename
SET::reference;
66
typename
SET::const_reference;
67
typename
SET::const_pointer;
68
69
{ s.find(k) } -> std::convertible_to<typename SET::const_iterator>;
70
{ s.insert(k) } -> std::convertible_to<std::pair<typename SET::iterator, bool>>;
71
};
72
73
template
<
typename
MAP>
74
concept
PairAssociativeContainer
=
requires
(MAP m,
typename
MAP::key_type k,
typename
MAP::mapped_type v) {
75
typename
MAP::value_type;
76
typename
MAP::key_type;
77
typename
MAP::mapped_type;
78
79
{ m[k] } -> std::convertible_to<typename MAP::mapped_type>;
80
{ m.find(k) } -> std::convertible_to<typename MAP::iterator>;
81
{ m.insert(std::make_pair(k, v)) } -> std::same_as<std::pair<typename MAP::iterator, bool>>;
82
};
83
84
// An allocation function. Can be used like <code>T* p = F()</code> to allocate
85
// a new object.
86
template
<
typename
F,
typename
T>
87
concept
AllocationFunction
=
88
std::invocable<F> && std::convertible_to<std::invoke_result_t<F>, T*>;
89
90
92
template
<
class
T>
93
concept
RefCounted
=
94
requires
(T&
x
)
95
{
96
{
x
.addRef() };
97
{
x
.release() };
98
};
99
100
101
}
// namespace detail
102
}
// namespace CxxUtils
103
104
105
106
#endif
// not CXXUTILS_CONCEPTS_H
SET
#define SET(n)
Definition
MD5.cxx:147
x
#define x
h
Header file for AthHistogramAlgorithm.
CxxUtils::detail::AllocationFunction
Definition
concepts.h:87
CxxUtils::detail::InputValIterator
Definition
concepts.h:55
CxxUtils::detail::IsBinaryPredicate
Definition
concepts.h:41
CxxUtils::detail::IsContiguousContainer
Definition
concepts.h:47
CxxUtils::detail::IsHash
Definition
concepts.h:30
CxxUtils::detail::PairAssociativeContainer
Definition
concepts.h:74
CxxUtils::detail::RefCounted
Has addRef() and release().
Definition
concepts.h:93
CxxUtils::detail::SimpleAssociativeContainer
Definition
concepts.h:60
CxxUtils
Definition
aligned_vector.h:29
detail
Definition
extract_histogram_tag.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0