There is a function to output instructions supported by the processor to the console. Help to remake that was saved in a file.

auto& outstream = std::cout; auto support_message = [&outstream](std::string isa_feature, bool is_supported) { outstream << isa_feature << (is_supported ? " supported" : " not supported") << std::endl; }; 
  • one
    Initialize outstream not as cout , but as an open ofstream ... Better yet, pass the link to ostream , where to write, as a parameter. - Harry
  • I do not shy in s ++. I tried it like this auto & outstream = ofstream f ("Test.txt"); Did not work. - ModNick
  • @ModNick: Ie you are not even familiar with the basic syntax of the language? - AnT
  • No) That's why I asked for help here. - ModNick

2 answers 2

 auto support_message = [](std::ostream& out, std::string isa_feature, bool is_supported) { return out << isa_feature << (is_supported ? " supported" : " not supported") << std::endl; }; 

Well then

 ofstream log("Logfile",ios::ate); support_message(cout,"feature",true); support_message(log,"feature",true); 

Like that.

    I did it like this. Works)

     ofstream log("Logfile.txt"); auto support_message = [&log](std::string isa_feature, bool is_supported) { log << isa_feature << (is_supported ? " supported" : " not supported") << std::endl; }; 
    • This option is bad using a global variable. Your support_message as a result works with only one thread, while it could work with any . - Harry