set/dset: prefer view overloads over span overloads
This lets us target both pointer ranges and dset objects with more or less the same code.
This commit is contained in:
parent
15c49a8437
commit
0fe14f038d
12
set/dset.hpp
12
set/dset.hpp
@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../view.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
@ -81,14 +83,15 @@ namespace cruft::set {
|
||||
///
|
||||
/// Items must be in sorted order, and must be a subset of this
|
||||
/// container.
|
||||
void erase (std::span<ValueT const> rhs)
|
||||
template <typename IteratorT>
|
||||
void erase (cruft::view<IteratorT> rhs)
|
||||
{
|
||||
*this = *this - rhs;
|
||||
}
|
||||
|
||||
void erase (ValueT const &val)
|
||||
{
|
||||
erase (std::span (&val, 1));
|
||||
erase (cruft::view (&val, 1));
|
||||
}
|
||||
|
||||
/// Tests if the list is a subset of this container.
|
||||
@ -134,7 +137,8 @@ namespace cruft::set {
|
||||
return res;
|
||||
}
|
||||
|
||||
dset operator- (std::span<ValueT const> rhs) const
|
||||
template <typename IteratorT>
|
||||
dset operator- (cruft::view<IteratorT> rhs) const
|
||||
{
|
||||
dset res;
|
||||
auto const pos = std::set_difference (
|
||||
@ -159,7 +163,7 @@ namespace cruft::set {
|
||||
|
||||
dset operator- (dset const &rhs) const
|
||||
{
|
||||
return *this - std::span (rhs.m_data.data (), rhs.m_size);
|
||||
return *this - cruft::view (rhs);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user