Boost logo

Boost Users :

From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2008-01-30 15:06:08


Michael Fawcett <michael.fawcett <at> gmail.com> writes:

>
> On Jan 30, 2008 12:48 PM, Joaquín Mª López Muñoz <joaquin <at> tid.es> wrote:
> >
> > Not all STL containers provide an allocator ctor (associative containers
> > don't),
>
> Ah, sorry for the blanket statement (I had been using vector and list
> as my test structures thus far). Do you know the rational or
> historical reasons for not including those ctors in the associative
> containers?

Umm... Well, there's a theoretic possibility that we hit
ambiguity:

  set(const Compare&=Compare(),const Allocator&=Allocator());
  set(const Allocator&);

What happens if Compare is the same type as Allocator? The
possibility of this happening in the real world is close
to zero, but theoretically it is possible:

  template<typename T>
  struct less_and_allocator:
    public std::allocator<T>,
    public std::less<T>
  {
  };

  typedef std::set<
    int,
    less_and_allocator<int>,
    less_and_allocator<int>
> paradoxical_set;

I'm holding your proposal in my todo list, but I have to think
it over a bit.

Thank you,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net