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
499 stars 43 forks source link

error in finding as_bytes when byte-lite is present #40

Closed tsung-wei-huang closed 4 years ago

tsung-wei-huang commented 5 years ago

I think you should do this in order to enable as_bytes function to your byte-lite library?

#if span_HAVE( BYTE ) || span_HAVE( NONSTD_BYTE )
using span_lite::as_bytes;
using span_lite::as_writeable_bytes;
#endif

The original code doesn't have span_HAVE( NONSTD_BYTE ) and that causes me error in using as_bytes even though bite-lite exists.

martinmoene commented 5 years ago

@tsung-wei-huang, sorry for reacting only now,

span-lite provides as_bytes(), as_writable_bytes() and std::as_bytes(), std::as_writable_bytes() via namespace nonstd.

So one can either use (example on Godbolt)

fun( span_lite::as_bytes( spn ) );  // explicitly specify namespace

or

using namespace nonstd;
fun( as_bytes( spn ) );  // make everything from nonstd available

or

fun( as_bytes( spn ) );  // ADL: argument-dependent lookup
martinmoene commented 4 years ago

Assuming this can be closed.