Skip to content

Commit

Permalink
Let span_FEATURE_NON_MEMBER_FIRST_LAST_SUB make make_span() available (
Browse files Browse the repository at this point in the history
…#35, thanks to @Flamefire)
  • Loading branch information
martinmoene committed Jan 16, 2019
1 parent 689e26f commit 615e38e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ Define this to 1 to provide function `same()` to test if two spans refer as iden
### Provide `first()`, `last()` and `subspan()` functions
-D<b>span_FEATURE_NON_MEMBER_FIRST_LAST_SUB</b>=1

This comment has been minimized.

Copy link
@Flamefire

Flamefire Jan 16, 2019

BTW: Could you also have the example define not have a value or the default value? I got confused reading this as I expected that the define show is the default. IMO easiest would be to simply have span_FEATURE_NON_MEMBER_FIRST_LAST_SUB here

This comment has been minimized.

Copy link
@martinmoene

martinmoene Jan 16, 2019

Author Owner

My preference is to show how the macro is expected to be used as I (prefer to) use #if and not #ifdef in the code.
I do agree that the shown value must correspond to the default behavior (this was/is my intention but it clearly didn't work out that way).

This comment has been minimized.

Copy link
@Flamefire

Flamefire Jan 16, 2019

I do agree that the shown value must correspond to the default behavior (this was/is my intention but it clearly didn't work out that way).

👍 to that

Define this to 1 to provide functions `first()`, `last()` and `subspan()`. This requires `make_span()` functions to be available, see `span_FEATURE_MAKE_SPAN_TO_STD`. Default is undefined.
Define this to 1 to provide functions `first()`, `last()` and `subspan()`. This implies `span_FEATURE_MAKE_SPAN` to provide functions `make_span()` that are required for this feature. Default is undefined.
### Provide `make_span()` functions
-D<b>span_FEATURE_MAKE_SPAN</b>=1
Define this to 1 to provide creator functions `nonstd::make_span()`. Note that `span_FEATURE_MAKE_SPAN` takes precedence over `span_FEATURE_MAKE_SPAN_TO_STD`. Default is undefined.
Define this to 1 to provide creator functions `nonstd::make_span()`. This feature is implied by using `span_FEATURE_NON_MEMBER_FIRST_LAST_SUB=1`. Note that `span_FEATURE_MAKE_SPAN` takes precedence over `span_FEATURE_MAKE_SPAN_TO_STD`. Default is undefined.
-D<b>span_FEATURE_MAKE_SPAN_TO_STD</b>=14
Define this to the highest C++ language version for which to provide creator functions `nonstd::make_span()`, like 98, 03, 11, 14, 17, 20. Note that `span_FEATURE_MAKE_SPAN` takes precedence over `span_FEATURE_MAKE_SPAN_TO_STD`. Default is undefined.
Expand Down
7 changes: 2 additions & 5 deletions include/nonstd/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,13 +1162,10 @@ as_writeable_bytes( span<T,Extent> spn ) span_noexcept
#endif // span_HAVE( BYTE ) || span_HAVE( NONSTD_BYTE )

// extensions: non-member views:
// this feature implies the presence of make_span()

#if span_FEATURE( NON_MEMBER_FIRST_LAST_SUB ) && span_CPP11_120

#if ! span_FEATURE( MAKE_SPAN )
# error nonstd::span: non-member first(), last() and subspan() require make_span(), see span_FEATURE_MAKE_SPAN
#endif

template< extent_t Count, class T >
span_constexpr auto
first( T & t ) -> decltype( make_span(t).template first<Count>() )
Expand Down Expand Up @@ -1247,7 +1244,7 @@ using span_lite::same;

// make_span() [span-lite extension]:

#if span_FEATURE( MAKE_SPAN )
#if span_FEATURE( MAKE_SPAN ) || span_FEATURE( NON_MEMBER_FIRST_LAST_SUB )

namespace nonstd {
namespace span_lite {
Expand Down

0 comments on commit 615e38e

Please sign in to comment.