Minimal C++ replacement for rvec
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 14 Dec 2014 14:19:11 +0000 (16:19 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 5 Jan 2015 22:30:24 +0000 (23:30 +0100)
commitc9cbb4cd22c0037997090aee69723b13723e9560
tree392b7cda727f484fc32086f7dfb6b07ba124a196
parente743cd14a64633a958ec0949a2be700e7d3b0f4d
Minimal C++ replacement for rvec

Add a C++ class that acts as rvec, but also supports placement in STL
containers (i.e., is default-constructible, copy-constructible, and
assignable) and can be returned from functions.  There is some ugly
reinterpret_casting required for rvec arrays to make this work, which
requires that the compiler generates compatible layouts for the class
and rvec.  The tests ensure that this is the case, but it could be nice
to check some more exotic compilers as well, unless someone knows the
C/C++ standards well enough to say that this layout is always ensured.

Passing RVec as 'const rvec &' unfortunately also needs an explicit
function call because of issues with cppcheck and MSVC.

Minimal solution to #1017.

Change-Id: I79be58bf7be2a78f787f470044b3b5abf234ec0c
src/gromacs/math/CMakeLists.txt
src/gromacs/math/tests/CMakeLists.txt [new file with mode: 0644]
src/gromacs/math/tests/vectypes.cpp [new file with mode: 0644]
src/gromacs/math/vectypes.h
src/gromacs/selection/nbsearch.cpp
src/gromacs/selection/nbsearch.h
src/gromacs/selection/tests/nbsearch.cpp
src/gromacs/trajectoryanalysis/modules/angle.cpp
src/gromacs/trajectoryanalysis/tests/surfacearea.cpp