Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
// -*- C++ -*-
//===-------------------------- concepts ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_CONCEPTS
#define _LIBCPP_CONCEPTS

/*
    concepts synopsis
namespace std {
  // [concepts.lang], language-related concepts
  // [concept.same], concept same_as
  template<class T, class U>
    concept same_as = see below;

  // [concept.derived], concept derived_from
  template<class Derived, class Base>
    concept derived_from = see below;

  // [concept.convertible], concept convertible_to
  template<class From, class To>
    concept convertible_to = see below;

  // [concept.commonref], concept common_reference_with
  template<class T, class U>
    concept common_reference_with = see below;

  // [concept.common], concept common_with
  template<class T, class U>
    concept common_with = see below;

  // [concepts.arithmetic], arithmetic concepts
  template<class T>
    concept integral = see below;
  template<class T>
    concept signed_integral = see below;
  template<class T>
    concept unsigned_integral = see below;
  template<class T>
    concept floating_point = see below;

  // [concept.assignable], concept assignable_from
  template<class LHS, class RHS>
    concept assignable_from = see below;

  // [concept.swappable], concept swappable
  namespace ranges {
    inline namespace unspecified {
      inline constexpr unspecified swap = unspecified;
    }
  }
  template<class T>
    concept swappable = see below;
  template<class T, class U>
    concept swappable_with = see below;

  // [concept.destructible], concept destructible
  template<class T>
    concept destructible = see below;

  // [concept.constructible], concept constructible_from
  template<class T, class... Args>
    concept constructible_from = see below;

  // [concept.default.init], concept default_initializable
  template<class T>
    concept default_initializable = see below;

  // [concept.moveconstructible], concept move_constructible
  template<class T>
    concept move_constructible = see below;

  // [concept.copyconstructible], concept copy_constructible
  template<class T>
    concept copy_constructible = see below;

  // [concept.equalitycomparable], concept equality_comparable
  template<class T>
    concept equality_comparable = see below;
  template<class T, class U>
    concept equality_comparable_with = see below;

  // [concept.totallyordered], concept totally_ordered
  template<class T>
    concept totally_ordered = see below;
  template<class T, class U>
    concept totally_ordered_with = see below;

  // [concepts.object], object concepts
  template<class T>
    concept movable = see below;
  template<class T>
    concept copyable = see below;
  template<class T>
    concept semiregular = see below;
  template<class T>
    concept regular = see below;

  // [concepts.callable], callable concepts
  // [concept.invocable], concept invocable
  template<class F, class... Args>
    concept invocable = see below;

  // [concept.regularinvocable], concept regular_invocable
  template<class F, class... Args>
    concept regular_invocable = see below;

  // [concept.predicate], concept predicate
  template<class F, class... Args>
    concept predicate = see below;

  // [concept.relation], concept relation
  template<class R, class T, class U>
    concept relation = see below;

  // [concept.equiv], concept equivalence_relation
  template<class R, class T, class U>
    concept equivalence_relation = see below;

  // [concept.strictweakorder], concept strict_weak_order
  template<class R, class T, class U>
    concept strict_weak_order = see below;
}

*/

#include <__config>
#include <__functional_base>
#include <type_traits>
#include <utility>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>

_LIBCPP_BEGIN_NAMESPACE_STD

#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)

// [concept.same]

template<class _Tp, class _Up>
concept __same_as_impl = _VSTD::_IsSame<_Tp, _Up>::value;

template<class _Tp, class _Up>
concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;

// [concept.derived]
template<class _Dp, class _Bp>
concept derived_from =
  is_base_of_v<_Bp, _Dp> &&
  is_convertible_v<const volatile _Dp*, const volatile _Bp*>;

// [concept.convertible]
template<class _From, class _To>
concept convertible_to =
  is_convertible_v<_From, _To> &&
  requires(add_rvalue_reference_t<_From> (&__f)()) {
    static_cast<_To>(__f());
  };

// [concept.commonref]
template<class _Tp, class _Up>
concept common_reference_with =
  same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> &&
  convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&
  convertible_to<_Up, common_reference_t<_Tp, _Up>>;

// [concept.common]
template<class _Tp, class _Up>
concept common_with =
  same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
  requires {
    static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>());
    static_cast<common_type_t<_Tp, _Up>>(declval<_Up>());
  } &&
  common_reference_with<
    add_lvalue_reference_t<const _Tp>,
    add_lvalue_reference_t<const _Up>> &&
  common_reference_with<
    add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
    common_reference_t<
      add_lvalue_reference_t<const _Tp>,
      add_lvalue_reference_t<const _Up>>>;

// [concepts.arithmetic], arithmetic concepts
template<class _Tp>
concept integral = is_integral_v<_Tp>;

template<class _Tp>
concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;

template<class _Tp>
concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;

template<class _Tp>
concept floating_point = is_floating_point_v<_Tp>;

// [concept.assignable]
template<class _Lhs, class _Rhs>
concept assignable_from =
  is_lvalue_reference_v<_Lhs> &&
  common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> &&
  requires (_Lhs __lhs, _Rhs&& __rhs) {
    { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;
  };

// [concept.destructible]

template<class _Tp>
concept destructible = is_nothrow_destructible_v<_Tp>;

// [concept.constructible]
template<class _Tp, class... _Args>
concept constructible_from =
    destructible<_Tp> && is_constructible_v<_Tp, _Args...>;

// [concept.default.init]

template<class _Tp>
concept __default_initializable = requires { ::new _Tp; };

template<class _Tp>
concept default_initializable = constructible_from<_Tp> &&
    requires { _Tp{}; } && __default_initializable<_Tp>;

// [concept.moveconstructible]
template<class _Tp>
concept move_constructible =
  constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;

// [concept.copyconstructible]
template<class _Tp>
concept copy_constructible =
  move_constructible<_Tp> &&
  constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
  constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
  constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;

// Whether a type is a class type or enumeration type according to the Core wording.
template<class _Tp>
concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;

// [concept.swappable]
namespace ranges::__swap {
  // Deleted to inhibit ADL
  template<class _Tp>
  void swap(_Tp&, _Tp&) = delete;


  // [1]
  template<class _Tp, class _Up>
  concept __unqualified_swappable_with =
    (__class_or_enum<remove_cvref_t<_Tp>> || __class_or_enum<remove_cvref_t<_Up>>) &&
    requires(_Tp&& __t, _Up&& __u) {
      swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u));
    };

  struct __fn;

  template<class _Tp, class _Up, size_t _Size>
  concept __swappable_arrays =
    !__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> &&
    extent_v<_Tp> == extent_v<_Up> &&
    requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) {
      __swap(__t[0], __u[0]);
    };

  template<class _Tp>
  concept __exchangeable =
    !__unqualified_swappable_with<_Tp&, _Tp&> &&
    move_constructible<_Tp> &&
    assignable_from<_Tp&, _Tp>;

  struct __fn {
    // 2.1   `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and...
    // *The name `swap` is used here unqualified.
    template<class _Tp, class _Up>
    requires __unqualified_swappable_with<_Tp, _Up>
    constexpr void operator()(_Tp&& __t, _Up&& __u) const
    noexcept(noexcept(swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
    {
      swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u));
    }

    // 2.2   Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and...
    template<class _Tp, class _Up, size_t _Size>
    requires __swappable_arrays<_Tp, _Up, _Size>
    constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const
    noexcept(noexcept((*this)(*__t, *__u)))
    {
      // TODO(cjdb): replace with `ranges::swap_ranges`.
      for (size_t __i = 0; __i < _Size; ++__i) {
        (*this)(__t[__i], __u[__i]);
      }
    }

    // 2.3   Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models...
    template<__exchangeable _Tp>
    constexpr void operator()(_Tp& __x, _Tp& __y) const
    noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>)
    {
      __y = _VSTD::exchange(__x, _VSTD::move(__y));
    }
  };
} // namespace ranges::__swap

namespace ranges::inline __cpo {
  inline constexpr auto swap = __swap::__fn{};
} // namespace ranges::__cpo

template<class _Tp>
concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); };

template<class _Tp, class _Up>
concept swappable_with =
  common_reference_with<_Tp, _Up> &&
  requires(_Tp&& __t, _Up&& __u) {
    ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Tp>(__t));
    ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Up>(__u));
    ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u));
    ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t));
  };

// [concept.booleantestable]
template<class _Tp>
concept __boolean_testable_impl = convertible_to<_Tp, bool>;

template<class _Tp>
concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) {
  { !std::forward<_Tp>(__t) } -> __boolean_testable_impl;
};

// [concept.equalitycomparable]
template<class _Tp, class _Up>
concept __weakly_equality_comparable_with =
  requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
    { __t == __u } -> __boolean_testable;
    { __t != __u } -> __boolean_testable;
    { __u == __t } -> __boolean_testable;
    { __u != __t } -> __boolean_testable;
  };

template<class _Tp>
concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>;

template<class _Tp, class _Up>
concept equality_comparable_with =
  equality_comparable<_Tp> && equality_comparable<_Up> &&
  common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
  equality_comparable<
    common_reference_t<
      __make_const_lvalue_ref<_Tp>,
      __make_const_lvalue_ref<_Up>>> &&
  __weakly_equality_comparable_with<_Tp, _Up>;

// [concept.totallyordered]

template<class _Tp, class _Up>
concept __partially_ordered_with =
  requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
    { __t <  __u } -> __boolean_testable;
    { __t >  __u } -> __boolean_testable;
    { __t <= __u } -> __boolean_testable;
    { __t >= __u } -> __boolean_testable;
    { __u <  __t } -> __boolean_testable;
    { __u >  __t } -> __boolean_testable;
    { __u <= __t } -> __boolean_testable;
    { __u >= __t } -> __boolean_testable;
  };

template<class _Tp>
concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>;

template<class _Tp, class _Up>
concept totally_ordered_with =
  totally_ordered<_Tp> && totally_ordered<_Up> &&
  equality_comparable_with<_Tp, _Up> &&
  totally_ordered<
    common_reference_t<
      __make_const_lvalue_ref<_Tp>,
      __make_const_lvalue_ref<_Up>>> &&
  __partially_ordered_with<_Tp, _Up>;

// [concepts.object]
template<class _Tp>
concept movable =
  is_object_v<_Tp> &&
  move_constructible<_Tp> &&
  assignable_from<_Tp&, _Tp> &&
  swappable<_Tp>;

template<class _Tp>
concept copyable =
  copy_constructible<_Tp> &&
  movable<_Tp> &&
  assignable_from<_Tp&, _Tp&> &&
  assignable_from<_Tp&, const _Tp&> &&
  assignable_from<_Tp&, const _Tp>;

template<class _Tp>
concept semiregular = copyable<_Tp> && default_initializable<_Tp>;

template<class _Tp>
concept regular = semiregular<_Tp> && equality_comparable<_Tp>;

// [concept.invocable]
template<class _Fn, class... _Args>
concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
  _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving
};

// [concept.regular.invocable]
template<class _Fn, class... _Args>
concept regular_invocable = invocable<_Fn, _Args...>;

// [concept.predicate]
template<class _Fn, class... _Args>
concept predicate =
  regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;

// [concept.relation]
template<class _Rp, class _Tp, class _Up>
concept relation =
  predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> &&
  predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>;

// [concept.equiv]
template<class _Rp, class _Tp, class _Up>
concept equivalence_relation = relation<_Rp, _Tp, _Up>;

// [concept.strictweakorder]
template<class _Rp, class _Tp, class _Up>
concept strict_weak_order = relation<_Rp, _Tp, _Up>;

#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // _LIBCPP_CONCEPTS