Make vec.h const-correct with both C and C++
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 10 Aug 2014 04:17:20 +0000 (07:17 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Sun, 10 Aug 2014 04:37:53 +0000 (06:37 +0200)
commit6f2a3703ee50529969a655aeec8bffd94c5dc8ab
tree655637ac58baddb25ce1f5e37402ac687f05d4e0
parentd8b2d526f2140fabb6ee1a39f45b9a598287a732
Make vec.h const-correct with both C and C++

C and C++ have different semantics for const if a function parameter has
multiple indirections (e.g., a double pointer or a 2D array).  If such a
parameter is not modified by the function, it is tricky to write
const-correct code using such functions:
 - If the parameter is declared const, then C will give a warning if a
   non-const value is passed.
 - If the parameter is not declared const, then C++ will give an error
   if a const value is passed.
Added a macro that allows using a single declaration in vec.h for
functions that take matrix values as input parameters, and still making
it possible to pass both non-const and const values to such parameters
in both C and C++.

Change-Id: Ifca3ff6842489c3a1040a8261ba429d96409fc21
src/gromacs/math/vec.h
src/gromacs/utility/basedefinitions.h