1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/cstring/strrchr.hpp
2012-10-06 00:58:56 +09:00

25 lines
642 B
C++
Raw Blame History

#ifndef SPROUT_CSTRING_STRRCHR_HPP
#define SPROUT_CSTRING_STRRCHR_HPP
#include <cstddef>
#include <sprout/config.hpp>
namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// 7.21.5.5 strrchr ŠÖ<C5A0>
inline SPROUT_CONSTEXPR char const*
strrchr(char const* s, int c) {
return *s == static_cast<char>(c) && (!*s || !sprout::strrchr(s + 1, c))? s
: !*s ? nullptr
: sprout::strrchr(s + 1, c)
;
}
inline SPROUT_CONSTEXPR char*
strrchr(char* s, int c) {
return const_cast<char*>(sprout::strrchr(const_cast<char const*>(s), c));
}
} // namespace sprout
#endif // #ifndef SPROUT_CSTRING_STRRCHR_HPP