Consider
auto x=foo(), y;
Is it legal? (I would suggest that this implies that it yis of the same type as x). Although this specific example may not be very useful, consider
template<typename some_type>
void func(some_type const&x, some_type const&y)
{
for(auto i=std::begin(x),j=std::begin(y); i!=std::end(x) && j!=std::end(y); ) {
...
}
}
Here ithey jare the same types (since both come from the same type of operations on objects of the same type), therefore it seems completely safe and reasonable, since it allows you to avoid declaring the corresponding type (it is best to use with decltype(), i.e. through deduction again).
However, the Intel compiler (version 14.0.1) warns me that
warning
, ? - , auto?
edit. , , . , :
struct Neighbour { ... };
typedef std::vector<Neighbour> NeighbourList;
NeighbourList const&A;
NeighbourList const&B;
...
const auto K = std::max(A.size(),B.size());
auto k = 0*K;
for(auto iA=A.begin(),iB=B.begin(); k!=K; ++k,++iA,++iB)
...
( for - )