Como surgiu o std :: vectorbool?

15

Hoje, praticamente todos os desenvolvedores de C ++ concordam que std::vector<bool> foi um erro, pois não é enganadoramente um contêiner, e seus casos de uso se sobrepõem em grande parte aos de std::bitset .

Como isso foi votado no padrão? Foi controverso na época? Quais foram os principais argumentos de apoio?

    
por xcvii 10.08.2016 / 21:53
fonte

1 resposta

10

De Herb Sutter usando a referência citada:

The vector specialization was intentionally put into the standard to provide an example of how to write a proxied container. A "proxied container" is a container whose objects you don't get at directly; instead of giving you pointers or references to a contained object, a proxied container gives you proxy objects that can be used to indirectly access or manipulate a contained object. Proxied collections can be useful in cases where the objects within the collection cannot always be reliably accessed directly as though they were in memory, as for example with a disk-based collection that automatically pages pieces of itself in and out of memory under the covers as needed. So the idea was to show how to make such a proxied collection meet the requirements of a "container" in the sense defined by the standard library.

E sim, houve discussão na época.

  1. For all the gory details, surf to DejaNews and do a power search for Subject="vector and bool" and Forum="c++". The discussions took place in Jan/Feb 1997. You will also find more recent discussions from people asking how to turn off the vector specialization; see the end of this article for my advice.

O resto é história. E eu odeio ver uma pergunta sem resposta com links tão bons.

    
por 10.11.2016 / 14:34
fonte

Tags