Boost logo

Boost :

From: Mohammed (miqbal_at_[hidden])
Date: 2004-02-11 15:15:08


If I am not wrong, VTL is using Boost. I can see more than one file from
Boost libraries.Some of these files are:
config.hpp
smart_ptr.hpp
type_traits.hpp
utility.hpp

Then how you will convert VTL to use Boost if it is already is based on
Boost?

Sorry for not understanding.
Mohammed

----- Original Message -----
From: "Powell, Gary" <powellg_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Wednesday, February 11, 2004 7:34 PM
Subject: RE: [boost] VTL question (sorry if this is slightly off-topic)

> 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?
> ----------------------------------
> Gary > Yes, I'm planning on using the new Iterator Adaptors and converting
the VTL library to use boost.
>
> ---------------------------
> 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...
> ----------------------------------------------
>
> Gary > If you are asking me to write this code, well I'm not likely to get
around to it. However I'd be glad to review it as an addition to the
library. We generally stayed with the STL model of no virtual functions. In
the meantime you might like to look at the Iterator Adaptor library and
generate your own special view container.
>
> -Gary-
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk