view: add some brief explanatory comments

This commit is contained in:
Danny Robson 2018-12-16 16:25:04 +11:00
parent 8047bf0f83
commit 49b8594a73

View File

@ -230,27 +230,23 @@ namespace cruft {
///////////////////////////////////////////////////////////////////////
/// Returns true if the size of the view is zero.
constexpr bool
empty (void) const noexcept
{
return m_begin == m_end;
}
//---------------------------------------------------------------------
// the return type of size _should_ be whatever std::distance returns,
// 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.
///--------------------------------------------------------------------
/// Returns the number of items in the view.
constexpr auto
size (void) const noexcept
{
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
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<
view<BeginT,BeginT>,
view<BeginT,EndT>
@ -275,7 +275,7 @@ namespace cruft {
}
//---------------------------------------------------------------------
///--------------------------------------------------------------------
template <
typename IndexT,
typename = std::enable_if_t<std::is_integral_v<IndexT>>