In Modern C++, we can use std::end on native arrays. I wanted to ask how does this work to understand the performance considerations for this.
            Asked
            
        
        
            Active
            
        
            Viewed 115 times
        
    0
            
            
        - 
                    1It works [like this](http://en.cppreference.com/w/cpp/iterator/end) – Nicol Bolas Feb 17 '17 at 07:41
- 
                    See also Motti's answer [to this related question](http://stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array). – juanchopanza Feb 17 '17 at 07:42
1 Answers
1
            
            
        If you have an array called a with size N, then std::end(a) means the same thing as a + N. It doesn't need to do any run-time work to find the size of the array, because the size is known at compile time.
Note that std::end won't work on a pointer. It will only work on an array that has not been decayed to a pointer, so the size information is statically present at the call site.
 
    
    
        Brian Bi
        
- 111,498
- 10
- 176
- 312
