Skip to content

Commit

Permalink
Fix incorrect casts in memory search functions
Browse files Browse the repository at this point in the history
  • Loading branch information
beached committed Jan 4, 2025
1 parent 138013c commit 1506352
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions include/daw/daw_string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -1734,18 +1734,16 @@ namespace daw {
#if defined( DAW_IS_CONSTANT_EVALUATED )
if( not DAW_IS_CONSTANT_EVALUATED( ) ) {
if constexpr( sizeof( CharT ) == 1 ) {
void const *r =
std::memchr( reinterpret_cast<char const *>( first ),
static_cast<char>( c ), sz );
void const *r = std::memchr( static_cast<void const *>( first ),
static_cast<char>( c ), sz );
if( r == nullptr ) {
return npos;
}
return static_cast<std::size_t>( static_cast<CharT const *>( r ) -
first );
} else if constexpr( sizeof( CharT ) == 2 ) {
void const *r =
::wmemchr( reinterpet_cast<wchar_t const *>( first ),
static_cast<wchar_t>( c ), sz );
wchar_t *r = ::wmemchr( reinterpret_cast<wchar_t const *>( first ),
static_cast<wchar_t>( c ), sz );
if( r == nullptr ) {
return npos;
}
Expand Down

0 comments on commit 1506352

Please sign in to comment.