refactor: Make Span an alias of std::span

This uses a macro, which can be a bit more brittle than an alias
template. However, class template argument deduction for alias templates
is only implemented in clang-19.
This commit is contained in:
MarcoFalke
2024-12-18 16:59:35 +01:00
parent fa27e36717
commit fadccc26c0
3 changed files with 3 additions and 182 deletions

View File

@ -856,14 +856,14 @@ class A
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
that are not language lawyers.
- Use `Span` as function argument when it can operate on any range-like container.
- Use `std::span` as function argument when it can operate on any range-like container.
- *Rationale*: Compared to `Foo(const vector<int>&)` this avoids the need for a (potentially expensive)
conversion to vector if the caller happens to have the input stored in another type of container.
However, be aware of the pitfalls documented in [span.h](../src/span.h).
```cpp
void Foo(Span<const int> data);
void Foo(std::span<const int> data);
std::vector<int> vec{1,2,3};
Foo(vec);