mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add <cstring> and <cwchar> compatible constexpr functions
This commit is contained in:
parent
fe255a5e74
commit
b04dea6002
26 changed files with 526 additions and 103 deletions
|
@ -8,27 +8,10 @@
|
|||
#ifndef SPROUT_CWCHAR_WMEMCHR_HPP
|
||||
#define SPROUT_CWCHAR_WMEMCHR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/ptr_index_iterator.hpp>
|
||||
#include <sprout/algorithm/find.hpp>
|
||||
#include <sprout/cstring/memchr.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR wchar_t const*
|
||||
wmemchr_impl(wchar_t const* found, wchar_t const* last) {
|
||||
return found == last ? nullptr
|
||||
: found
|
||||
;
|
||||
}
|
||||
inline SPROUT_CONSTEXPR wchar_t*
|
||||
wmemchr_impl(wchar_t* found, wchar_t* last) {
|
||||
return found == last ? nullptr
|
||||
: found
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// wmemchr
|
||||
//
|
||||
|
@ -37,28 +20,12 @@ namespace sprout {
|
|||
//
|
||||
inline SPROUT_CONSTEXPR wchar_t const*
|
||||
wmemchr(wchar_t const* s, wchar_t c, size_t n) {
|
||||
return sprout::detail::wmemchr_impl(
|
||||
sprout::ptr_unindex(
|
||||
sprout::find(
|
||||
sprout::ptr_index(s), sprout::ptr_index(s, n),
|
||||
c
|
||||
)
|
||||
),
|
||||
s + n
|
||||
);
|
||||
return sprout::detail::memchr(s, c, n);
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t*
|
||||
wmemchr(wchar_t* s, wchar_t c, size_t n) {
|
||||
return sprout::detail::wmemchr_impl(
|
||||
sprout::ptr_unindex(
|
||||
sprout::find(
|
||||
sprout::ptr_index(s), sprout::ptr_index(s, n),
|
||||
c
|
||||
)
|
||||
),
|
||||
s + n
|
||||
);
|
||||
return sprout::detail::memchr(s, c, n);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue