view: add some brief explanatory comments
This commit is contained in:
parent
8047bf0f83
commit
49b8594a73
22
view.hpp
22
view.hpp
@ -230,27 +230,23 @@ namespace cruft {
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
/// Returns true if the size of the view is zero.
|
||||||
constexpr bool
|
constexpr bool
|
||||||
empty (void) const noexcept
|
empty (void) const noexcept
|
||||||
{
|
{
|
||||||
return m_begin == m_end;
|
return m_begin == m_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
///--------------------------------------------------------------------
|
||||||
// the return type of size _should_ be whatever std::distance returns,
|
/// Returns the number of items in the view.
|
||||||
// or something else that makes sense for the iterators we've been
|
|
||||||
// handed.
|
|
||||||
//
|
|
||||||
// but it's a pain in the arse to use sizes that aren't unsigned given
|
|
||||||
// that other libraries need to compare sizes pretty often and
|
|
||||||
// everything else in the world tends to be unsigned.
|
|
||||||
constexpr auto
|
constexpr auto
|
||||||
size (void) const noexcept
|
size (void) const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<size_type> (std::distance (m_begin, m_end));
|
return static_cast<size_type> (std::distance (m_begin, m_end));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
///--------------------------------------------------------------------
|
||||||
|
/// Returns a subview of the first `count` elements of this view.
|
||||||
[[nodiscard]] constexpr auto
|
[[nodiscard]] constexpr auto
|
||||||
redim (size_type count) const
|
redim (size_type count) const
|
||||||
{
|
{
|
||||||
@ -261,7 +257,11 @@ namespace cruft {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
///--------------------------------------------------------------------
|
||||||
|
/// Returns two subviews split at `pos`.
|
||||||
|
///
|
||||||
|
/// The first view extends from `begin` to `pos`, and the second view
|
||||||
|
/// extends from `pos` to `end`.
|
||||||
[[nodiscard]] constexpr std::pair<
|
[[nodiscard]] constexpr std::pair<
|
||||||
view<BeginT,BeginT>,
|
view<BeginT,BeginT>,
|
||||||
view<BeginT,EndT>
|
view<BeginT,EndT>
|
||||||
@ -275,7 +275,7 @@ namespace cruft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
///--------------------------------------------------------------------
|
||||||
template <
|
template <
|
||||||
typename IndexT,
|
typename IndexT,
|
||||||
typename = std::enable_if_t<std::is_integral_v<IndexT>>
|
typename = std::enable_if_t<std::is_integral_v<IndexT>>
|
||||||
|
Loading…
Reference in New Issue
Block a user