BVLC/caffe — pull request #945 by longjon (2014-08-18 09:18:54+00:00)
Title: Fix types of SetUp, Forward, Backward, and gradient checker calls

Currently, vectors of blobs that are output arguments (such as Forward's top and Backward's bottom) have the type `vector*`. This type was chosen following the rule that outputs should be always be pointers. However, the semantics of this type are not correct for its use in Caffe; they allow modification of the vector itself (such as adding blobs, or changing the elements to point to other blobs), which will break Caffe. The real output arguments in these cases are the blobs themselves, which are correctly passed in via pointers. This incongruity also leads to a bunch of line noise, since every reference to an argument of this form must be dereferenced before it can be indexed, which in turn causes confusion.

This PR changes all such output arguments to have type `const vector&`, thus cleaning up code and turning dynamic errors into static ones.

(One might also observe that input vectors don't have quite the right type -- they are also `const vector&`, which allows modification of the input blobs. Unfortunately this is more difficult to solve, as blob vectors have to be used both as inputs and outputs, and C++ lacks container covariance.)

I think there is a general consensus(?) among BVLC folk that this is the right thing to do. Nevertheless, some reasons _not_ to merge this PR are:
* it changes a lot of types (albeit internal ones), which might interfere with people's development
* it makes the types of input and output arguments the same, which is a bit confusing (however, it's usually clear from reading whether a function goes from `top` to `bottom` or vice versa)