How to get info about which GPU and CPU player has in C++?

You can get them from WindowsPlatformSurvey.cpp or IOSPlatformSurvey.cpp
inside of
\Engine\Source\Runtime\ApplicationCore and the specific platform folder

You could probably try to access it through the abstract layer of
ApplicationCore/GenericPlatform

Unreal also has a benchmark tool built in to set optimized settings based on hardware.