
Am 15.05.2010 23:59, schrieb Neil Groves:
I feel compelled to suggest caution at performing type-erasure at an iterator level. This would often be the wrong place to incur runtime overhead for compiler-time advantage. The deterioration in locality of data, the worsening of cache-line performance and reduced in-lining capability would often make this a poor design choice. Indeed there were a number of older library designs that used runtime polymorphism with iterator hierarchies that ultimately discovered that this approach was vastly inferior to the generic iterator approach of the standard library. However I can certainly see that this is useful across module interface boundaries for small collections etc. [snip] Thank you for an interesting problem. I do wonder if it might be a good idea to provide a type-erasure Boost.Range adaptor so that you could write something like:
map_instance | boost::adaptors::map_values | boost::adaptors::type_erased<int, boost::forward_traversal_tag>
Is there much interest in using the library in this way? I'm happy to implement this if there is.
Yes, please. I would love to see a type-erased range and a type-erasing adaptor - exactly for the reason you pointed out. -Christopher