фиксированной длины. Тип может быть массив C-стиля, std :: array , std :: span или пользовательский контейнер. Я могу проверить условия контейнера
, как показано в коде ниже, но я не могу получить его до
проверить условие длины. < /P>
Код: Выделить всё
template
concept fixed_container =
requires (T const& t)
{
{std::size(t)} -> std::same_as;
{std::begin(t)};
{std::end(t)};
}
// && std::declval().size() == N // Error: 'declval() must not be used!'
// && T::size() == N // Error: 'call to non-static member function without an object argument'
;
// These should all be correct
static_assert( fixed_container);
static_assert(!fixed_container);
static_assert( fixed_container);
static_assert(!fixed_container);
static_assert( fixed_container);
static_assert(!fixed_container);
Подробнее здесь: https://stackoverflow.com/questions/794 ... ng-concept
Мобильная версия