Код: Выделить всё
#include
#include
#include
#include
template
requires std::ranges::view
class ContainerView : public std::ranges::view_interface
{
private:
Range range_{};
std::ranges::iterator_t begin_{ std::begin(range_) };
std::ranges::iterator_t end_{ std::end(range_) };
public:
ContainerView() = default;
constexpr ContainerView(Range r): range_(std::move(r)), begin_(std::begin(r)), end_(std::end(r)){}
constexpr auto begin() const { return begin_; }
constexpr auto end() const { return end_; }
};
template
ContainerView(Range&& range) -> ContainerView;
int main()
{
std::vector vec;
ContainerView view{vec};
}
Есть ли какая-то польза от того, что Range выводится как std::vector& вместо std::vector?
Подробнее здесь: https://stackoverflow.com/questions/798 ... ion-guides