mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user