Merge pull request #2432 from gruenich/feature/c-style-casts

Replace C-style pointer cast by static_cast or const_cast