Come è nato lo std :: vector bool?

15

Oggi, praticamente tutti gli sviluppatori C ++ concordano sul fatto che std::vector<bool> sia stato un errore poiché non è ingannevolmente un contenitore, e i suoi casi d'uso si sovrappongono in larga misura a quelli di std::bitset .

In che modo è stato votato nello standard? Era controverso all'epoca? Quali sono stati i principali argomenti di supporto?

    
posta xcvii 10.08.2016 - 21:53
fonte

1 risposta

10

Da Herb Sutter usando il riferimento citato:

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 sì, c'era una discussione in quel momento.

  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.

Il resto è storia. E odio vedere una domanda senza risposta con link così buoni.

    
risposta data 10.11.2016 - 14:34
fonte

Leggi altre domande sui tag