Boost logo

Boost :

From: Andreas Huber (ah2003_at_[hidden])
Date: 2004-05-20 06:54:33


Dear Boosters

Some old implementations of std::allocator don't provide the rebind member
template (e.g. MSVC6.0 stdlib). This keeps code as the following from
compiling:

    typedef std::map<
      const state_base_type *, event_queue_type,
      std::less< const state_base_type * >,
      typename allocator_type::template rebind< // *** here ***
        std::pair< const state_base_type * const, event_queue_type >
>::other
> deferred_map_type;

However, this map will internally not allocate objects of the type
std::pair< const state_base_type * const, event_queue_type > anyway but
rather of some implementation-defined tree node type. So, the above typedef
could also be written as follows, ...

    typedef std::map<
      const state_base_type *, event_queue_type,
      std::less< const state_base_type * >,
      allocator_type
> deferred_map_type;

which should work with just about any implementation of the std library, as
long as the used container is a list, (multi)set or (multi)map.

Now, the questions are:

- Does the standard allow the second variant (I haven't found anything pro
or contra)?
- Even if the standard does not allow it or is silent on it, would anyone
bother to write the technically more correct first variant? If yes, even at
the expense of making the code compileable on fewer compilers (or having to
clutter the code with more #ifdefs)?

Thanks & Regards,

Andreas


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