fix: explicitly check operator[] in is_contiguous

Prevent false positives when the container itself does not have `operator[](size_t)`, but the target type of one of the non-explicit user-defined conversion functions does.
This commit is contained in:
Yat Ho 2026-06-25 01:01:32 +08:00
parent 588b3a0f8f
commit 74343496d7

View File

@ -493,9 +493,10 @@ inline FMT_CONSTEXPR auto get_container(OutputIt it) ->
template <typename T, typename Enable = void>
struct is_contiguous : std::false_type {};
template <typename T>
struct is_contiguous<T, void_t<decltype(std::declval<T&>().data()),
decltype(std::declval<T&>().size()),
decltype(std::declval<T&>()[size_t()])>>
struct is_contiguous<T,
void_t<decltype(std::declval<T&>().data()),
decltype(std::declval<T&>().size()),
decltype(std::declval<T&>().operator[](size_t()))>>
: std::true_type {};
} // namespace detail