I would like to write a concept that would allow me to verify if a given statement, using ADL, is valid and has a proper return type.
In my specific case, I want to write a String
concept that should enforce the following requirements:
The type has
begin
andend
semantics for both itsconst
and non-const
flavors:// Akin to what this function does for `T` and `T const` template< typename T > auto test(T& t) { using std::begin; return begin(t); } // calling test with `T` and `T const` should be valid.
The return types of
begin
andend
are consistent for bothconst
and non-const
flavors and they satisfy thestd::contiguous_iterator
concept.
So far I went with a trait implementation like the following:
namespace Adl {
using std::begin;
template< typename T >
using HasBeginT = decltype(begin(std::declval< T >()));
}
template< typename T >
using HasBegin = std::experimental::is_detected< Adl::HasBeginT, T >;
But I would like to directly embed this ADL usage in the definition of my constraint instead.