Library: convenience function to take addresses

just a wrapper based on 5749a621

While implementing this, also simplified the way
a const iterator can be defined for taking addresses
This commit is contained in:
Fischlurch 2013-04-15 03:07:15 +02:00
parent 642f2e0e89
commit d953d4e6af
3 changed files with 23 additions and 10 deletions

View file

@ -263,6 +263,7 @@ namespace iter_stl {
typedef typename SEQ::iterator Iter;
typedef RangeIter<Iter> Range;
typedef DistinctIter<Range> DistinctVals;
typedef AddressExposingIter<Range> Addrs;
};
template<class SEQ>
@ -271,6 +272,7 @@ namespace iter_stl {
typedef typename SEQ::const_iterator Iter;
typedef RangeIter<Iter> Range;
typedef DistinctIter<Range> DistinctVals;
typedef AddressExposingIter<Range> Addrs;
};
}//(End) traits/helpers
@ -290,6 +292,18 @@ namespace iter_stl {
}
/** @return Lumiera Forward Iterator
* exposing the address of each Element within a STL
*/
template<class CON>
inline typename _SeqT<CON>::Addrs
eachAddress (CON& coll)
{
typedef typename _SeqT<CON>::Addrs Addresses;
return Addresses (eachElm (coll));
}
/** @return Lumiera Forward Iterator to yield
* each key of a map/multimap
*/

View file

@ -527,8 +527,6 @@ namespace lib {
typedef CON Container;
typedef TY ElemType;
typedef typename RemovePtr<TY>::Type ValueType;
template<class T2>
struct SimilarIter ///< rebind to a similarly structured Iterator with value type T2
{
@ -706,15 +704,11 @@ namespace lib {
class AddressExposingIter
: public lib::BoolCheckable<AddressExposingIter<IT> >
{
public:
typedef typename IT::value_type ** pointer;
typedef typename IT::value_type *& reference;
typedef typename IT::value_type * value_type;
typedef typename IT::pointer _Ptr;
private:
IT i_; ///< nested source iterator
mutable value_type currPtr_;
mutable _Ptr currPtr_;
void
@ -728,6 +722,11 @@ namespace lib {
public:
typedef typename IT::pointer const* pointer;
typedef typename IT::pointer const& reference;
typedef typename IT::pointer const value_type;
/** AddressExposingIter is always created
* by wrapping an existing iterator.
*/
@ -755,7 +754,7 @@ namespace lib {
return currPtr_;
}
pointer
_Ptr
operator->() const
{
return currPtr_;

View file

@ -341,7 +341,7 @@ namespace test{
// since we're exposing the pointer as value, the solution is to add
// the const on the immediately wrapped iterator type
typedef vector<int>::const_iterator ConstRawIter;
typedef ConstIter<Range> ConstRange;
typedef RangeIter<ConstRawIter> ConstRange;
typedef AddressExposingIter<ConstRange> ConstAddrIter;
ConstAddrIter iic(ConstRange(Range(numbz.begin(), numbz.end())));