strtoi() is complementary to strtoui() returning size_t. But, intptr_t
is complementary to uintptr_t, and ptrdiff_t is complementary to size_t.
I know it doesn't matter on flat-memory platforms, but nevertheless, we
try to keep things organized in a portable way.
Signed-off-by: Simon Rozman <simon@rozman.si>
Those are frequently used:
- UTF8: for exception message formatting
- ACP(OCP): for generic (console) output
Signed-off-by: Simon Rozman <simon@rozman.si>
The standard C++ approach is preferred over legacy C-style string
operations. Some helpers have clean standard C++ implementation on
std::string(_view) classes. All were just a simple .data() and .size()
wrappers for legacy C functions.
The main concern is the amount of helpers that require maintenance.
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>
This avoids painful `.get()` in every `stdex::sprintf()` call. We could
use C++ polymorphism to add other sprintf variants, but the argument
combinations would explode.
Signed-off-by: Simon Rozman <simon@rozman.si>
Nice catch: when calling with basic_bol::match(nullptr, 5, 5), the
method addresses null[4].
Turned this condition into debug assert, as (nullptr, 5, 5) is invalid
input parameter combination.
diag_file::size() was setting the m_state and returning 0 on error,
which violated original size() convention not to change stream state and
to return fsize_max on error.
Changing m_state prevented declaring size() method as const before.
cache::seek() was missing size() return value check.
Signed-off-by: Simon Rozman <simon@rozman.si>
No need to use locale-specific character type detection when ASCII.
Locale-specific implementation on Windows is not that very fast.
Signed-off-by: Simon Rozman <simon@rozman.si>
"C"-locale is basically ASCII while (Microsoft) implementation is not
quite performant to our likes. We can do faster.
Signed-off-by: Simon Rozman <simon@rozman.si>
This is analogous to string.hpp's strlen, strcpy, strcat, which use C++
polymorphism rather than function name decorations for char/wchar_t
flavors.
Signed-off-by: Simon Rozman <simon@rozman.si>