fix recursion depth: cstring algorithm

This commit is contained in:
bolero-MURAKAMI 2013-01-13 01:16:48 +09:00
parent f26032dce8
commit b51b14efa9
25 changed files with 792 additions and 142 deletions

View file

@ -3,27 +3,22 @@
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/iterator/ptr_index_iterator.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/find.hpp>
#include <sprout/cstring/strlen.hpp>
namespace sprout {
//
// wcslen
//
// recursion depth:
// O(log N)
//
inline SPROUT_CONSTEXPR std::size_t
wcslen(wchar_t const* s) {
return !*s ? 0
: 1 + sprout::wcslen(s + 1)
;
return sprout::strlen(s);
}
inline SPROUT_CONSTEXPR std::size_t
wcslen(wchar_t const* s, std::size_t n) {
return sprout::distance(
sprout::as_iterator(s),
sprout::find(sprout::as_iterator(s), sprout::as_iterator(s, n), L'\0')
);
return sprout::strlen(s, n);
}
} // namespace sprout