 
            
            
            
            
                16 Oct
                
                    2017
                
            
            
                16 Oct
                
                '17
                
            
            
            
        
    
                7:45 p.m.
            
        Den 16-10-2017 kl. 19:18 skrev Thorsten Ottosen via Boost:
I do want to focus on simple properties from a user's perspective. Some cases to consider:
# case 1: push_back from empty state ------------------------------------
vector<int> v; v.reserve( N );
This guarantees N pushes without exceptions and without reallocation.
# case 2: push_back from unknown state --------------------------------------
vector<int> v; ... v.reserve( v.size() + N );
This guarantees N pushes without exceptions and without reallocation.
A note: this is why I absolutely loathe reserve() compared to a function called v.anticipate( N ) which would work equally well in both cases. -Thorsten