mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
porting sscrisk/CEL
This commit is contained in:
parent
ad60c8c530
commit
db20f64991
181 changed files with 2531 additions and 607 deletions
31
sprout/cstring/memchr.hpp
Normal file
31
sprout/cstring/memchr.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef SPROUT_CSTRING_MEMCHR_HPP
|
||||
#define SPROUT_CSTRING_MEMCHR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR void const* memchr_impl(unsigned char const* s, char c, std::size_t n) {
|
||||
return !n ? 0
|
||||
: *s == c ? s
|
||||
: sprout::detail::memchr_impl(s + 1, c, n - 1)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// 7.21.5.1 memchr ŠÖ<C5A0>”
|
||||
inline SPROUT_CONSTEXPR void const* memchr(void const* s, int c, size_t n) {
|
||||
return sprout::detail::memchr_impl(static_cast<unsigned char const*>(s), static_cast<unsigned char>(c), n);
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR void* memchr(void* s, int c, size_t n) {
|
||||
return const_cast<void*>(
|
||||
sprout::detail::memchr_impl(static_cast<unsigned char*>(s), static_cast<unsigned char>(c), n)
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CSTRING_MEMCHR_HPP
|
Loading…
Add table
Add a link
Reference in a new issue