Better have Windows and Linux implementations in separate files and in separate classes. Common methods can be virtual. Additionally a socket can be opened in constructor and closed in a destructor for basic RAII. Host and port can be passed as an arg.
A better alternative to having #ifdef is if constexpr (isWindowsPlatform()).
A better alternative to having #ifdef is if constexpr (isWindowsPlatform()).
No, this is bogus. In non-template functions, if constexpr doesn't work like how you think - both sides have to be calling functions that have been declared. Even in function templates, non-dependent calls will be looked up immediately (these are the two-phase name lookup rules).
2
u/MiaowMeoow Nov 19 '23
Better have Windows and Linux implementations in separate files and in separate classes. Common methods can be virtual. Additionally a socket can be opened in constructor and closed in a destructor for basic RAII. Host and port can be passed as an arg.
A better alternative to having #ifdef is if constexpr (isWindowsPlatform()).
Good video !