Skip to content

Constrain distance function using is_iterator type trait#96

Open
jeremy-murphy wants to merge 4 commits into
boostorg:developfrom
jeremy-murphy:patch-1
Open

Constrain distance function using is_iterator type trait#96
jeremy-murphy wants to merge 4 commits into
boostorg:developfrom
jeremy-murphy:patch-1

Conversation

@jeremy-murphy
Copy link
Copy Markdown

distance will match anything, which gets annoying when your geometry algorithm for distance is... distance.

@jeremy-murphy
Copy link
Copy Markdown
Author

Looks like this works in principle, now to add a unit test. (haha, so much for TDD...)

@Lastique
Copy link
Copy Markdown
Member

One potential issue is that is_iterator is a heuristic and may return false for unconventional iterators that don't expose their category. Though category/traversal is needed to select distance_impl internally, so maybe that's a moot point.

@Lastique
Copy link
Copy Markdown
Member

We should use std::enable_if since Boost.Iterator requires C++11 now.

@Lastique
Copy link
Copy Markdown
Member

The same restriction should probably be applied to advance.

@jeremy-murphy
Copy link
Copy Markdown
Author

One potential issue is that is_iterator is a heuristic and may return false for unconventional iterators that don't expose their category. Though category/traversal is needed to select distance_impl internally, so maybe that's a moot point.

Yeah, that's what I figured -- if it unconditionally uses iterator_traversal then we should be able to use that expectation to conditionally enable it. However, in the brief testing I did (clang/libc++), it didn't actually disable it, so there might be more to it. In other words, I'm more concerned about false positives than false negatives.

@jeremy-murphy
Copy link
Copy Markdown
Author

We should use std::enable_if since Boost.Iterator requires C++11 now.

OK, sure thing.

@amlel-el-mahrouss
Copy link
Copy Markdown

@jeremy-murphy, hey, I started working on the unit test for #96.

amlel-el-mahrouss added a commit to amlel-el-mahrouss/iterator that referenced this pull request May 14, 2026
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
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.

3 participants