Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/stdx/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ span(R &&) -> span<std::remove_reference_t<detail::range_reference_t<R>>>;

template <typename T, std::size_t N>
constexpr auto ct_capacity_v<span<T, N>> = N;

template <typename T>
constexpr auto ct_capacity_v<span<T, dynamic_extent>> =
detail::ct_capacity_fail<span<T, dynamic_extent>>{};
} // namespace v1
} // namespace stdx

Expand Down
3 changes: 2 additions & 1 deletion test/fail/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
atomic_bool_dec
call_by_need
ct_format_mismatch
dynamic_span_no_ct_capacity
dynamic_container_no_ct_capacity
dynamic_std_span_no_ct_capacity
dynamic_stdx_span_no_ct_capacity
tuple_index_out_of_bounds
tuple_equality_mismatch
tuple_equality_with_element
Expand Down
13 changes: 13 additions & 0 deletions test/fail/dynamic_stdx_span_no_ct_capacity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdx/iterator.hpp>
#include <stdx/span.hpp>

#include <array>
#include <iterator>

// EXPECT: Type does not support compile-time capacity

auto main() -> int {
auto a = std::array<int, 4>{};
auto s = stdx::span{std::begin(a), std::end(a)};
constexpr auto c = stdx::ct_capacity(s);
}
Loading