you can define a copyToClipboard function in a separate header file and use preprocessor directives like #ifdef _WIN32 ... #elif defined (linux) ... to provide a windows or linux implementation of the copy depending on the platform and then just use #include "copy_to_clipboard.h" everywhere
i still learn C++ so i focus on Windows only and WinApi for now and do not care about crossplattform, except it is really trivial
codepointToUTF8 has an unnecessary const
My IDE, gave me a grey underline saying ... can be made const so i did that because i thought it would be good practise to make "effectively const" variable so variables i never change, const, if the IDE already notes this. Is this wrong?
are you really sure about the order in which bitwise operations are performed in the codepointToUTF8 function? these are easy to messup, it would be better if you put parenthesis to clear that up for anybody reading
When i wrote this i put parenthesis but my IDE greyed them out and marked that they are redundant, that is why i removed them
the function getPasswordSize as far as I can see is supposed to read an integer passed from console and turn it into an int? first it has an unnecessary const & for it's input, then it uses a weird way to parse an integer from a character array using std::from_chars when you can use std::stoi and exceptions it throws to provide an extra information to the user instead of writing to a std::err and exiting the program - the function that returns password size shouldn't be responsible for writing to console and exiting the program
But std::from_chars is more modern than std::stoi and does not have the overhead of first constructing a std::string out of the char*, since the command line argument is a char*, and it is more performant anyways i think.
and i do not have to catch the error from std::stoi, but i check for the error