2012-04-01 13:15:09 +00:00
|
|
|
|
#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 <20><EFBFBD>
|
2012-10-05 15:58:56 +00:00
|
|
|
|
inline SPROUT_CONSTEXPR char const*
|
|
|
|
|
strrchr(char const* s, int c) {
|
2012-04-01 13:15:09 +00:00
|
|
|
|
return *s == static_cast<char>(c) && (!*s || !sprout::strrchr(s + 1, c))? s
|
|
|
|
|
: !*s ? nullptr
|
|
|
|
|
: sprout::strrchr(s + 1, c)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-05 15:58:56 +00:00
|
|
|
|
inline SPROUT_CONSTEXPR char*
|
|
|
|
|
strrchr(char* s, int c) {
|
2012-04-01 13:15:09 +00:00
|
|
|
|
return const_cast<char*>(sprout::strrchr(const_cast<char const*>(s), c));
|
|
|
|
|
}
|
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_CSTRING_STRRCHR_HPP
|