Visual Computing Library
Loading...
Searching...
No Matches
bit_set.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_CONCEPTS_SPACE_BIT_SET_H
24#define VCL_CONCEPTS_SPACE_BIT_SET_H
25
26#include <vclib/concepts/const_correctness.h>
27
28#include <concepts>
29
30namespace vcl {
31
39template<typename T>
40concept BitProxyConcept = requires (T&& obj) {
41 requires std::convertible_to<T, bool>;
42
43 obj = bool();
44 obj |= bool();
45 obj &= bool();
46 obj /= bool();
47};
48
56template<typename T>
57concept BitSetConcept = requires (T&& obj) {
58 RemoveRef<T>();
59 RemoveRef<T>({uint(), uint()});
60
61 { obj.size() } -> std::same_as<std::size_t>;
62
63 { obj.at(uint()) } -> std::convertible_to<bool>;
64 { obj[uint()] } -> std::convertible_to<bool>;
65
66 { obj.all() } -> std::same_as<bool>;
67 { obj.any() } -> std::same_as<bool>;
68 { obj.none() } -> std::same_as<bool>;
69
70 { obj == obj } -> std::same_as<bool>;
71 { obj <=> obj } -> std::convertible_to<std::partial_ordering>;
72
73 // non const requirements
74 requires IsConst<T> || requires {
75 { obj.at(uint()) } -> BitProxyConcept;
76 { obj[uint()] } -> BitProxyConcept;
77
78 obj.set();
79 obj.set(bool(), uint());
80 obj.reset();
81 obj.reset(uint());
82 obj.flip();
83 obj.flip(uint());
84 };
85};
86
87} // namespace vcl
88
89#endif // VCL_CONCEPTS_SPACE_BIT_SET_H
BitProxyConcept is satisfied only if a class provides the member functions specified in this concept....
Definition bit_set.h:40
BitSetConcept is satisfied only if a class provides the member functions specified in this concept....
Definition bit_set.h:57
The IsConst concept is satisfied if T satisfies one of the following conditions:
Definition const_correctness.h:43