martinmoene / span-lite

span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library
Boost Software License 1.0
495 stars 40 forks source link

Update to proposal p0122r7 #27

Closed martinmoene closed 5 years ago

martinmoene commented 6 years ago

p0122 - span: bounds-safe views for sequences of objects

See also Reddit: 2018 San Diego ISO C++ Committee Trip Report.

See also 2019-02 Kona ISO C++ Committee Trip Report.

Plan:


size(spn), ssize(spn)

In namespace nonstd::span_lite:

namespace nonstd { namespace span_lite {

template< class T, extent_t Extent /*= dynamic_extent*/ >
span_constexpr std::size_t size( span<T,Extent> const & spn )
{
    return static_cast<std::size_t>( spn.size() );
}

template< class T, extent_t Extent /*= dynamic_extent*/ >
span_constexpr std::ptrdiff_t ssize( span<T,Extent> const & spn )
{
    return static_cast<std::ptrdiff_t>( spn.size() );
}
}} // namespace

namespace nonstd { 
    using span_lite::size;
    using span_lite::ssize;
}