Declare operator?() as 'const'.

None of operator+(), operator-(), operator*() or operator/() modify
their object.  These methods are thus naturally declared as 'const'.
This commit is contained in:
Bård Skaflestad 2013-05-03 16:24:20 +02:00
parent 0a43fe68dd
commit bd240a31cb

View File

@ -76,7 +76,7 @@ namespace AutoDiff
}
/// Operator +
ForwardBlock operator+(const ForwardBlock& rhs)
ForwardBlock operator+(const ForwardBlock& rhs) const
{
std::vector<M> jac = jac_;
assert(numBlocks() == rhs.numBlocks());
@ -90,7 +90,7 @@ namespace AutoDiff
}
/// Operator -
ForwardBlock operator-(const ForwardBlock& rhs)
ForwardBlock operator-(const ForwardBlock& rhs) const
{
std::vector<M> jac = jac_;
assert(numBlocks() == rhs.numBlocks());
@ -104,7 +104,7 @@ namespace AutoDiff
}
/// Operator *
ForwardBlock operator*(const ForwardBlock& rhs)
ForwardBlock operator*(const ForwardBlock& rhs) const
{
int num_blocks = numBlocks();
std::vector<M> jac(num_blocks);
@ -121,7 +121,7 @@ namespace AutoDiff
}
/// Operator /
ForwardBlock operator/(const ForwardBlock& rhs)
ForwardBlock operator/(const ForwardBlock& rhs) const
{
int num_blocks = numBlocks();
std::vector<M> jac(num_blocks);