blob: 288ca07c1ce759166998f40afb42c38392c275ca (
plain) (
tree)
|
|
/*
Copyright 2022-2023 Gabriel Jensen.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
#ifndef zap_priv_cxxhdr_str
#define zap_priv_cxxhdr_str
#include <zap/bs.hh>
#include <zap/str.h>
namespace zap {
template<typename typ> constexpr auto streq(typ const * lstr,typ const * rstr) noexcept -> bool {
static_assert(::zap::ischrtyp<typ>,"Input type must be a character type.");
for (;;++lstr,++rstr) {
typ const lchr = *lstr;
typ const rchr = *rstr;
if (lchr != rchr) return false;
if (lchr == typ {0x0}) break;
}
return true;
}
template<typename typ> constexpr auto strlen(typ const * str) noexcept -> ::zap::sz {
static_assert(::zap::ischrtyp<typ>,"Input type must be a character type.");
typ const * const start = str;
while (*str++ != typ {0x0});
return static_cast<::zap::sz>(str - start) - 0x1u;
}
}
#endif
|