[pointer container] Wishlist: Iterating through nullable vectors and compiler firewalls

Two quick queries. Would it make sense to have the iterator increment and decrement operators and begin() member function of ptr_vector< nullable<> > skip missing records so that applications have no need to check? What is stopping pointer container classes from being used with opaque types as a compilation firewall? -- Andrew Hain Oasys http://www.oasys-software.com

Andrew Hain skrev:
Two quick queries.
Would it make sense to have the iterator increment and decrement operators and begin() member function of ptr_vector< nullable<> > skip missing records so that applications have no need to check?
Well, it is always a design trade-off. If we did that, then people who need to know the index of the null value is in trouble. I do think it would make sense to add some utility iterator/range: boost::ptr_vector<T> vec; ... BOOST_FOREACH( T& e, boost::filter_nulls(vec) ) or something. I'm open to naming ideas :-)
What is stopping pointer container classes from being used with opaque types as a compilation firewall?
Can you be more specific? I have some trouble knowing the precise problem. Thanks -Thorsten

Thorsten Ottosen <thorsten.ottosen <at> dezide.com> writes:
Andrew Hain skrev:
Two quick queries.
Would it make sense to have the iterator increment and decrement operators
and
begin() member function of ptr_vector< nullable<> > skip missing records so that applications have no need to check?
Well, it is always a design trade-off. If we did that, then people who need to know the index of the null value is in trouble.
I do think it would make sense to add some utility iterator/range:
boost::ptr_vector<T> vec; ... BOOST_FOREACH( T& e, boost::filter_nulls(vec) )
or something. I'm open to naming ideas
Something like that could be useful.
What is stopping pointer container classes from being used with opaque
types
as a compilation firewall?
Can you be more specific? I have some trouble knowing the precise problem.
I have been looking at replacing a homebrewed template class with ptr_vector. The homebrewed template supports opaque classes with a nasty trick that only allows the template to be used with types known to its definition; this is one of the reasons I am trying to replace it. During my test I created a clone template that calls a Clone() member function in each class and I got compiler errors when the class arguments to ptr_vector are undefined. Would opaque classes work with a separate out-of-line definition of each class?
Thanks
-Thorsten _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Andrew Hain
-
Thorsten Ottosen