Unlike Posix, Windows handles HANDLE (file, pipe) and SOCKET descriptors
differently. It uses different close(), different errno... So sys_object
was not usable for socket without templating operations to a traits
class.
Signed-off-by: Simon Rozman <simon@rozman.si>
It's useful to clone std handles when creating streams to write/read to
standard streams. As the stream we give handle to assumes the handle
ownership, it'd close the std handles in stream destructor.
Signed-off-by: Simon Rozman <simon@rozman.si>
Unfortunately, MSVC cannot deduce template parameters properly where
`const std::basic_string_view<...>` is the parameter. It requires
explicit type cast or explicit template type specification. Which kind
of voids the whole purpose of using std::basic_string_view to make the
client code simpler.
Example: https://gist.github.com/rozmansi/493911be70bdac08dc6826c976c5bbe4
Signed-off-by: Simon Rozman <simon@rozman.si>
The stdex::sys_info is instantiated for each compilation unit. To reduce
amount of copies, move it to a separate .hpp as system.hpp is almost
always #included.
Breaking-change: Add #include <stdex/sys_info.hpp>
Signed-off-by: Simon Rozman <simon@rozman.si>
While runtime asserts also served as MSVC Code Analysis hints, the lack
of asserts in Release builds provides no hints to Code Analysis which
rises a lot of warnings then.
Maybe I should learn how to use SAL to annotate <ptr, len> parameter
pairs to allow ptr==nullptr when and only when len==0? 😇
Signed-off-by: Simon Rozman <simon@rozman.si>
I am aware of the std::filesystem::path::preferred_separator, but we
are targeting C++14 and we need this as a precompiler macro to allow
concatenation of the path strings in precompile stage.
Signed-off-by: Simon Rozman <simon@rozman.si>
"sys_char" sticks out of "wchar_t", "char32_t", "uint32_t"...
Likewise, "sys_string" out of "string", "wstring", "u16string",
"u32string"...
Signed-off-by: Simon Rozman <simon@rozman.si>
Windows is very peculiar with #include <windows.h>. Besides we need some
OS primitive wrappers that are OS-specific.
Signed-off-by: Simon Rozman <simon@rozman.si>