If a type of a variable changes don't you want to *know* the new type of the variable?

Actually, not at all.


Consider this C++ code as an example:


std::vector<int> foo;

template<class T>
void process(T &data) { ... }

int test()
{
        auto copy = foo;
        process(copy);
        if (copy.size() == foo.size())
                foo = copy;
        return copy.size();
}



The word 'auto' protects against changes to the type of 'foo' (say, for example, if it was alter changed into std::deque).


No need to explicitly state the type of 'copy' anywhere.

Reply via email to