Share via


array::difference_type

The type of a signed distance between two elements.

typedef std::ptrdiff_t difference_type;

Remarks

The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is a synonym for the type std::ptrdiff_t.

Example

 

// std_tr1__array__array_difference_type.cpp 
// compile with: /EHsc 
#include <array> 
#include <iostream> 
 
typedef std::array<int, 4> Myarray; 
int main() 
    { 
    Myarray c0 = {0, 1, 2, 3}; 
 
// display contents " 0 1 2 3" 
    for (Myarray::const_iterator it = c0.begin(); 
        it != c0.end(); ++it) 
        std::cout << " " << *it; 
    std::cout << std::endl; 
 
// display distance first-last " -4" 
    Myarray::difference_type diff = c0.begin() - c0.end(); 
    std::cout << " " << diff; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 -4

Requirements

Header: <array>

Namespace: std

See Also

Reference

<array>

array Class (TR1)

array::size_type