TString.h Comilation errors due to C++ version despite ROOT having been compiled with correct version

It could be that your “some code” needs some special flag.
It could also be that it does not support “c++17” at all (e.g., it supports at most “c++14” or “c++11”).

For example, newer Geant 4 supports (note also “=14”): cmake -DGEANT4_BUILD_CXXSTD=14
Older Geant 4 supports (note also “=c++11”): cmake -DGEANT4_BUILD_CXXSTD=c++11