use C++ and add many `const` to avoid warnings