
On Sat, Oct 30, 2010 at 8:57 PM, David Abrahams
At Sat, 30 Oct 2010 17:55:35 -0400, Stirling Westrup wrote:
I am writing some algorithms to operate on MPL sequences, and I would like to use some form of concept checking to ensure that the types passed in that are supposed to be iterators are, in fact, iterators.
http://www.generic-programming.org/about/intro/concepts.php#refinement
Thanks. That answers one of my questions then.
I initially assumed that this meant that a random_access_iterator_tag was derived from a bidirectional_iterator_tag which was derived from a forward_iterator_tag.
That's a useful trick if you're calling runtime functions, but it wouldn't be useful for MPL as written.
I'm not so sure of that, but I'm willing to be convinced otherwise.
I'm not sure exactly how to help, because I can't quite tell where you're stuck, so let me ask a few questions:
0. Which iterator concept do you want to check for?
All of them. Right now I need to test for forward iterators but I have some algorithms planned that are likely to want random access iterators. I figure if I have to write one of the concept checks, I may as well write all three.
1. Do you understand the requirements of that concept?
This is the big kicker for me. As far as I can tell from the
documents, there are only three requirements, and two (for deref and
next) don't apply to past-the-end iterators.
Since I need
BOOST_MPL_ASSERT(( is_forward_iterator
2. Do you understand how to test if those requirements are met?
Well, I have never actually had to write a concept check before, as I've always been able to find an existing one to meet my needs, but I think I have a decent grasp of the theory. -- Stirling Westrup Programmer, Entrepreneur. https://www.linkedin.com/e/fpf/77228 http://www.linkedin.com/in/swestrup http://technaut.livejournal.com