Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickroberts committed Jan 14, 2025
1 parent a4bdb6a commit 4811445
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
# pr::any_view
# any_view

```cpp
#include <pr/any_view.hpp>

#include <algorithm>
#include <array>
#include <ranges>
#include <span>
#include <vector>

static_assert([] {
using enum pr::any_kind;
constexpr auto sum(pr::any_view<const int> view) {
return std::ranges::fold_left(view, 0, std::plus{});
}

pr::any_view<int, random_access | sized> view;
std::array arr{10, 20, 30, 40, 50};
std::vector vec{1, 2, 3};

view = arr;
view[4] = 42;
view = vec;
view[0] = 7;

return arr[4] == 42 and vec[0] == 7 and view.size() == 3;
}());
static_assert(150 == sum(std::array{10, 20, 30, 40, 50}));
static_assert(100 == sum(std::ranges::views::repeat(20, 5)));
static_assert(75 == sum(std::span<const int>{{5, 10, 15, 20, 25}}));
static_assert(15 == sum(std::vector{1, 2, 3, 4, 5}));
```
## Features:
## Features
- C++23 implementation
- Clang and GCC support (MSVC support planned)
- Fully constexpr and SFINAE-friendly
- Supports:
* Ranges of any iterator category including `contiguous_range<R>`
* `borrowed_range<R>`, `range<const R>`, `copyable<R>`, and `sized_range<R>`
- Type-erased interfaces for
* all input range categories including `contiguous_range<R>`
* `borrowed_range<R>`, `common_range<R>`, `copyable<R>`, `range<const R>`, and `sized_range<R>`
- No allocation performed for small view and iterator types

0 comments on commit 4811445

Please sign in to comment.