@@ -82,18 +82,9 @@ target_link_libraries(yourlib PUBLIC beman::any_view)
8282
8383## Reference
8484
85- ### Designs
86-
87- <details >
88- <summary ><code >ENUM</code > (default)</summary >
89-
9085Synopsis:
9186
9287``` cpp
93- #define BEMAN_ANY_VIEW_USE_ENUM () 1
94- #define BEMAN_ANY_VIEW_USE_TRAITS() 0
95- #define BEMAN_ANY_VIEW_USE_NAMED() 0
96-
9788namespace beman ::any_view {
9889
9990enum class any_view_options {
@@ -104,11 +95,7 @@ enum class any_view_options {
10495 contiguous = 0b0001111,
10596 sized = 0b0010000,
10697 borrowed = 0b0100000,
107- #if BEMAN_ANY_VIEW_USE_COPYABLE()
10898 copyable = 0b1000000,
109- #elif BEMAN_ANY_VIEW_USE_MOVE_ONLY()
110- move_only = 0b1000000,
111- #endif
11299};
113100
114101constexpr auto operator|(any_view_options l, any_view_options r) noexcept -> any_view_options;
@@ -133,11 +120,7 @@ class any_view : public std::ranges::view_interface<any_view<ElementT, OptionsV,
133120 using size_type = /*make-unsigned-like-t*/<DiffT>; // exposition-only
134121
135122 static constexpr bool copyable = // exposition-only
136- #if BEMAN_ANY_VIEW_USE_COPYABLE()
137123 (OptionsV & any_view_options::copyable) == any_view_options::copyable;
138- #elif BEMAN_ANY_VIEW_USE_MOVE_ONLY()
139- (OptionsV & any_view_options::move_only) != any_view_options::move_only;
140- #endif
141124
142125 static constexpr bool sized = // exposition-only
143126 (OptionsV & any_view_options::sized) == any_view_options::sized;
@@ -169,205 +152,8 @@ inline constexpr bool std::ranges::enable_borrowed_range<
169152 (OptionsV & beman::any_view::any_view_options::borrowed) == beman::any_view::any_view_options::borrowed;
170153```
171154
172- </details>
173-
174- <details>
175- <summary><code>TRAITS</code></summary>
176-
177- Synopsis:
178-
179- ```cpp
180- #define BEMAN_ANY_VIEW_USE_ENUM() 0
181- #define BEMAN_ANY_VIEW_USE_TRAITS() 1
182- #define BEMAN_ANY_VIEW_USE_NAMED() 0
183-
184- namespace beman::any_view {
185-
186- struct default_range_traits {};
187-
188- template <std::ranges::range RangeT>
189- struct range_traits {
190- using iterator_concept = /*range-concept-t*/<RangeT>;
191- using reference_type = std::ranges::range_reference_t<RangeT>;
192- using rvalue_reference_type = std::ranges::range_rvalue_reference_t<RangeT>;
193- using difference_type = std::ranges::range_difference_t<RangeT>;
194-
195- static constexpr bool sized = std::ranges::sized_range<RangeT>;
196- static constexpr bool borrowed = std::ranges::borrowed_range<RangeT>;
197- #if BEMAN_ANY_VIEW_USE_COPYABLE()
198- static constexpr bool copyable = std::copyable<RangeT>;
199- #elif BEMAN_ANY_VIEW_USE_MOVE_ONLY()
200- static constexpr bool move_only = not std::copyable<RangeT>;
201- #endif
202- };
203-
204- template <class ElementT, class RangeTraitsT = default_range_traits>
205- class any_view : public std::ranges::view_interface<any_view<ElementT, RangeTraitsT>> {
206- class iterator; // exposition-only
207- class sentinel; // exposition-only
208-
209- using difference_type = /*difference-type-or-t*/<std::ptrdiff_t, RangeTraitsT>; // exposition-only
210- using size_type = /*make-unsigned-like-t*/<difference_type>; // exposition-only
211-
212- static constexpr bool copyable = // exposition-only
213- #if BEMAN_ANY_VIEW_USE_COPYABLE()
214- /*copyable-or-v*/<false, RangeTraitsT>;
215- #elif BEMAN_ANY_VIEW_USE_MOVE_ONLY()
216- not /*move-only-or-v*/<false, RangeTraitsT>;
217- #endif
218-
219- static constexpr bool sized = /*sized-or-v*/<false, RangeTraitsT>; // exposition-only
220-
221- public:
222- template </*viewable-range-compatible-with*/<any_view> RangeT>
223- constexpr any_view(RangeT&& range);
224-
225- constexpr any_view(const any_view&) requires copyable;
226-
227- constexpr any_view(any_view&&) noexcept;
228-
229- constexpr auto operator=(const any_view&) -> any_view& requires copyable;
230-
231- constexpr auto operator=(any_view&&) noexcept -> any_view&;
232-
233- constexpr auto begin() -> iterator;
234-
235- constexpr auto end() -> sentinel;
236-
237- constexpr auto size() const -> size_type requires sized;
238- };
239-
240- } // namespace beman::any_view
241-
242- template <class ElementT, class RangeTraitsT>
243- inline constexpr bool std::ranges::enable_borrowed_range<beman::any_view::any_view<ElementT, RangeTraitsT>> =
244- /*borrowed-or-v*/<false, RangeTraitsT>;
245- ```
246-
247- </details >
248-
249- <details >
250- <summary ><code >NAMED</code ></summary >
251-
252- Synopsis:
253-
254- ``` cpp
255- #define BEMAN_ANY_VIEW_USE_ENUM () 0
256- #define BEMAN_ANY_VIEW_USE_TRAITS() 0
257- #define BEMAN_ANY_VIEW_USE_NAMED() 1
258-
259- namespace beman ::any_view {
260-
261- template <class T >
262- struct type_t {
263- using type = T;
264- };
265-
266- template <class T >
267- inline constexpr type_t<T > type{};
268-
269- template <class RefT,
270- class IterConceptT = std::input_iterator_tag,
271- class RValueRefT = /* as-rvalue-t* /<RefT >,
272- class DiffT = std::ptrdiff_t>
273- struct any_view_options {
274- type_t<RefT > reference_type;
275- type_t<IterConceptT > iterator_concept = {};
276- bool sized = false;
277- #if BEMAN_ANY_VIEW_USE_COPYABLE()
278- bool copyable = false;
279- #elif BEMAN_ANY_VIEW_USE_MOVE_ONLY()
280- bool move_only = false;
281- #endif
282- bool borrowed = false;
283- type_t<RValueRefT > rvalue_reference_type = {};
284- type_t<DiffT > difference_type = {};
285- };
286-
287- template <class ElementT, any_view_options OptionsV = {.reference_type = type<ElementT&>}>
288- class any_view : public std::ranges::view_interface<any_view<ElementT, OptionsV>> {
289- class iterator; // exposition-only
290- class sentinel; // exposition-only
291-
292- using difference_type = decltype(OptionsV.difference_type)::type; // exposition-only
293- using size_type = /*make-unsigned-like-t*/<difference_type>; // exposition-only
294-
295- static constexpr bool copyable = // exposition-only
296- #if BEMAN_ANY_VIEW_USE_COPYABLE()
297- OptionsV.copyable;
298- #elif BEMAN_ANY_VIEW_USE_MOVE_ONLY()
299- not OptionsV.move_only;
300- #endif
301-
302- static constexpr bool sized = OptionsV.sized; // exposition-only
303-
304- public:
305- template </* viewable-range-compatible-with* /<any_view> RangeT>
306- constexpr any_view(RangeT&& range);
307-
308- constexpr any_view(const any_view&) requires copyable;
309-
310- constexpr any_view(any_view&&) noexcept;
311-
312- constexpr auto operator=(const any_view&) -> any_view& requires copyable;
313-
314- constexpr auto operator=(any_view&&) noexcept -> any_view&;
315-
316- constexpr auto begin() -> iterator;
317-
318- constexpr auto end() -> sentinel;
319-
320- constexpr auto size() const -> size_type requires sized;
321- };
322-
323- } // namespace beman::any_view
324-
325- template <class ElementT, auto OptionsV>
326- inline constexpr bool std::ranges::enable_borrowed_range<beman::any_view::any_view<ElementT, OptionsV>> =
327- OptionsV.borrowed;
328- ```
329-
330- </details>
331-
332- ### Options
333-
334- <details>
335- <summary><code>COPYABLE</code> (default)</summary>
336-
337- Synopsis:
338-
339- ```cpp
340- #define BEMAN_ANY_VIEW_USE_COPYABLE() 1
341- #define BEMAN_ANY_VIEW_USE_MOVE_ONLY() 0
342- ```
343-
344- </details >
345-
346- <details >
347- <summary ><code >MOVE_ONLY</code ></summary >
348-
349- Synopsis:
350-
351- ``` cpp
352- #define BEMAN_ANY_VIEW_USE_COPYABLE () 0
353- #define BEMAN_ANY_VIEW_USE_MOVE_ONLY() 1
354- ```
355-
356- </details>
357-
358155## Building
359156
360- ### CMake configuration variables
361-
362- ```text
363- -DBEMAN_ANY_VIEW_DESIGN=ENUM
364- -DBEMAN_ANY_VIEW_DESIGN=TRAITS
365- -DBEMAN_ANY_VIEW_DESIGN=NAMED
366-
367- -DBEMAN_ANY_VIEW_OPTION=COPYABLE
368- -DBEMAN_ANY_VIEW_OPTION=MOVE_ONLY
369- ```
370-
371157There are workflows available in CMake presets such as `gcc-debug`:
372158
373159```bash
0 commit comments