Hello, I was reviewing the View Template Library (VTL) - see http://www.zib.de/weiser/vtl/ ... and have a few questions regarding Views
as applied to STL Maps.
 
I was also wondering if Boost was planning to eventually provide a VTL-like framework?

I'm looking for a type of View that provides read-only access to an STL map, with only const iterators, but also provides limited insertion and removal
access as well (as shown below):
 
This new limited View-like map will only allow clients to iterate using const iterators, and also provides only one public insert(const key&) and
one erase(const key&) method.
 
These insert and erase member functions need to be implemented as "Template Method Functions", as follows: (see Design Patterns)

* Note: these are shown using the latest SGI STL implementation (i.e., the
_M_t.insert_unique and _M_t.erase calls)

virtual bool preInsert(const value_type&)
{
        return true;
}

pair<iterator, bool> insert(const value_type& x)
{
        if(preInsert(x) {
                return _M_t.insert_unique(x);
        }
        return make_pair(end(), false); // make compiler happy
}
 
virtual bool preErase(const key_type&)
{
        return true;
}
 
size_type erase(const key_type& x)
{
        if(preErase(x) {
                return _M_t.erase(x);
        }
        return 0; // make compiler happy
}

The preInsert and preErase methods are virtual Hook Methods, and derived classes override these to add behavior to the (non-virtual) insert and erase
functions..
 
Another nice addition to this map view would be a const _Tp& operator[](const key_type& k) const function, implemented something like this:
 
const _Tp& operator[](const key_type& k) const
{
        const_iterator i = lower_bound(k);
        if(i == end() || key_comp(k, (*i).first)) // if i->first is >= k
                throw SearchError(k);
        return (*i).second;
}

* Note: this simple implementation assumes that the key can be converted to a string in the constructor of the SearchError exception object.
 
I have at least three Manager-like (Mediator) classes that can use this pattern (i.e., derived from this Map View class) as well as others that need
a vector view with a similar filtered design...

Thanks in advance,

~Matt Verona
Houston, Texas
USA