Note that std::ifstream opens files. Note that the article Configuring a Communications Resource that DavidLowndes-6766 references uses CreateFile. Serial ports are devices. You must open them as a device. CreateFile is the Windows function for opening files and devices. I do not know for sure that none of the Standard C++ classes can be used for devices but probably none of them can. Also, it is not possible to use streaming with a device such as a serial port.
See Serial Communications. It is old but still relevant. You might need to spend a month learning how to do serial communications. The following are more articles that might help.