[Concept Check] ContiguousIterator

Using BCC, s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ? I can't get any proper expression to check for this in a proper way.

joel falcou wrote:
Using BCC, s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I don't see how. That's a runtime property. Of course you could devise a trait that advertises those semantics and ensure the type satisfies that trait within the concept class. _____ Rob Stewart robert.stewart@sig.com Software Engineer, Core Software using std::disclaimer; Susquehanna International Group, LLP http://www.sig.com IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

At Tue, 05 Oct 2010 21:45:46 +0200, joel falcou wrote:
Using BCC,
Took me days to realize you didn't mean the Borland compiler ;-)
s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I can't get any proper expression to check for this in a proper way.
Yeah, it's a purely semantic distinction, so while you *can* refine RandomAccessIterator for it, there are no syntactic/structural checks you can add... unless, as Rob S points out, you add a trait somewhere and make it part of the ContiguousIterator concept. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Took me days to realize you didn't mean the Borland compiler ;-)
s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I can't get any proper expression to check for this in a proper way.
Yeah, it's a purely semantic distinction, so while you *can* refine RandomAccessIterator for it, there are no syntactic/structural checks you can add... unless, as Rob S points out, you add a trait somewhere and make it part of the ContiguousIterator concept.
-- Dave Abrahams BoostPro Computing
I would be interested in a trait, that could tell at compile time, if an iterator is a ContiguousIterator. I write a lot of code in C++, that needs to cooperate with old C code. Regards, Kris

On 05/10/10 20:45, joel falcou wrote:
Using BCC, s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I can't get any proper expression to check for this in a proper way.
Iterators will need to register nominally to the concept. Specialize it for pointers and any kind of normal vector-like iterator (too bad we don't have a standardized name for that). You may want to make sure it works correctly with iterator_adaptor as well.

On 07/10/10 13:13, Mathias Gaunard wrote:
On 05/10/10 20:45, joel falcou wrote:
Using BCC, s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I can't get any proper expression to check for this in a proper way.
Iterators will need to register nominally to the concept. Specialize it for pointers and any kind of normal vector-like iterator (too bad we don't have a standardized name for that).
You may want to make sure it works correctly with iterator_adaptor as well.
__gnu_cxx::__normal_iterator will forward the iterator_category from pointers already, so it doesn't need special care.

At Thu, 07 Oct 2010 13:23:14 +0100, Mathias Gaunard wrote:
On 07/10/10 13:13, Mathias Gaunard wrote:
On 05/10/10 20:45, joel falcou wrote:
Using BCC, s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I can't get any proper expression to check for this in a proper way.
Iterators will need to register nominally to the concept. Specialize it for pointers and any kind of normal vector-like iterator (too bad we don't have a standardized name for that).
You may want to make sure it works correctly with iterator_adaptor as well.
__gnu_cxx::__normal_iterator will forward the iterator_category from pointers already, so it doesn't need special care.
You could make the iterator category tag a class derived from random_access_iterator_tag. That would be a good protocol for new iterators, anyway. You'll need to specialize in order to retrofit this for existing iterator types. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

On 07/10/10 15:58, David Abrahams wrote:
At Thu, 07 Oct 2010 13:23:14 +0100, Mathias Gaunard wrote:
On 07/10/10 13:13, Mathias Gaunard wrote:
On 05/10/10 20:45, joel falcou wrote:
Using BCC, s there any way to refine RandomAccessIterator so the cocnept captures the fact that the address of two consecutive value iterated over are contiguous in memory ?
I can't get any proper expression to check for this in a proper way.
Iterators will need to register nominally to the concept. Specialize it for pointers and any kind of normal vector-like iterator (too bad we don't have a standardized name for that).
You may want to make sure it works correctly with iterator_adaptor as well.
__gnu_cxx::__normal_iterator will forward the iterator_category from pointers already, so it doesn't need special care.
You could make the iterator category tag a class derived from random_access_iterator_tag. That would be a good protocol for new iterators, anyway. You'll need to specialize in order to retrofit this for existing iterator types.
Ok so I wasn't that much braindead. I'll do this then ;) Thanks for the head up
participants (6)
-
David Abrahams
-
joel falcou
-
Joel Falcou
-
Krzysztof Czainski
-
Mathias Gaunard
-
Stewart, Robert