Skip to content

Provide reasonable default definition for is_contiguous#4731

Open
user202729 wants to merge 1 commit intofmtlib:mainfrom
user202729:use-contiguous-range
Open

Provide reasonable default definition for is_contiguous#4731
user202729 wants to merge 1 commit intofmtlib:mainfrom
user202729:use-contiguous-range

Conversation

@user202729
Copy link
Copy Markdown
Contributor

@user202729 user202729 commented Apr 6, 2026

Another attempt at #4716 . Compiling base-test.cc takes around 10 seconds (both before and after), probably is fine. (not sure what else to measure.)

Instead of using contiguous_iterator, I just check whether .data() can be called on it; if it can be called, the container is likely contiguous. Opinion?

Some code assumes that if it's contiguous, .resize() exists, so it won't work for e.g. std::array even though that one is contiguous. But then back_insert_iterator doesn't work on std::array either.

Directly define a partial specialization of is_contiguous with typename = void leads to ambiguous overload errors, which is backwards incompatible if someone else special-case is_contiguous. See for example https://github.com/user202729/fmt/actions/runs/24015836992/job/70035092887

@user202729 user202729 marked this pull request as draft April 6, 2026 01:59
@user202729 user202729 force-pushed the use-contiguous-range branch 2 times, most recently from 8b0fd20 to c9a57d4 Compare April 6, 2026 02:07
@user202729 user202729 force-pushed the use-contiguous-range branch from c9a57d4 to 5f956f9 Compare April 6, 2026 02:13
@user202729 user202729 marked this pull request as ready for review April 6, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant