Some operations can be checked for at compile time, e.g. with static_assert, rather than at runtime. For example, Vector3D(...) + Vector4D(...) will cause a compile time failure, while VectorKD(x,y,z) + VectorKD(a,b,c,d) will cause a runtime failure. Similarly, std::get<4>(ParticleIndexPair) will cause a compile time failure, while ParticleIndexPair[4] will cause a runtime failure. We cannot test specifically for compile time failures in Python since often we add additional checks in the SWIG wrappers, and we generally only see runtime failures there.
We want to test specifically for compile time failures so that we can safely remove redundant runtime checks. We could do this at the ctest level, e.g. https://stackoverflow.com/questions/30155619/expected-build-failure-tests-in-cmake. However, we want to make sure that the failure is specifically from static_assert, and not a missing header, wrong compiler command line options, etc. So most likely we need to run the C++ compiler in a subprocess and apply a regex to its output.
Some operations can be checked for at compile time, e.g. with
static_assert
, rather than at runtime. For example,Vector3D(...) + Vector4D(...)
will cause a compile time failure, whileVectorKD(x,y,z) + VectorKD(a,b,c,d)
will cause a runtime failure. Similarly,std::get<4>(ParticleIndexPair)
will cause a compile time failure, whileParticleIndexPair[4]
will cause a runtime failure. We cannot test specifically for compile time failures in Python since often we add additional checks in the SWIG wrappers, and we generally only see runtime failures there.We want to test specifically for compile time failures so that we can safely remove redundant runtime checks. We could do this at the
ctest
level, e.g. https://stackoverflow.com/questions/30155619/expected-build-failure-tests-in-cmake. However, we want to make sure that the failure is specifically fromstatic_assert
, and not a missing header, wrong compiler command line options, etc. So most likely we need to run the C++ compiler in a subprocess and apply a regex to its output.