view: ::size/::size_hint in_place support for single type views
This commit is contained in:
@@ -660,9 +660,11 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Returns the number of entities that have the given element.
|
||||
* @tparam Pol Dummy template parameter used for sfinae purposes only.
|
||||
* @return Number of entities that have the given element.
|
||||
*/
|
||||
[[nodiscard]] size_type size() const noexcept {
|
||||
template<typename..., deletion_policy Pol = Policy>
|
||||
[[nodiscard]] std::enable_if_t<Pol != deletion_policy::in_place, size_type> size() const noexcept {
|
||||
if constexpr(Policy == deletion_policy::swap_and_pop) {
|
||||
return leading ? leading->size() : size_type{};
|
||||
} else {
|
||||
@@ -671,6 +673,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Estimates the number of entities iterated by the view.
|
||||
* @tparam Pol Dummy template parameter used for sfinae purposes only.
|
||||
* @return Estimated number of entities iterated by the view.
|
||||
*/
|
||||
template<typename..., deletion_policy Pol = Policy>
|
||||
[[nodiscard]] std::enable_if_t<Pol == deletion_policy::in_place, size_type> size_hint() const noexcept {
|
||||
return leading ? leading->size() : size_type{};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether a view is empty.
|
||||
* @return True if the view is empty, false otherwise.
|
||||
|
||||
Reference in New Issue
Block a user