diff options
Diffstat (limited to 'zap/include/zap/mem.hh')
-rw-r--r-- | zap/include/zap/mem.hh | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/zap/include/zap/mem.hh b/zap/include/zap/mem.hh deleted file mode 100644 index b237cbc..0000000 --- a/zap/include/zap/mem.hh +++ /dev/null @@ -1,76 +0,0 @@ -/* - 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_mem -#define zap_priv_cxxhdr_mem - -#include <zap/bs.hh> -#include <zap/mem.h> - -namespace zap { - template<typename desttyp,typename srctyp> struct cpret { - desttyp * dest; - srctyp * src; - }; -} - -namespace zap { - template<typename desttyp,typename srctyp> zap_attr_iln inline ::zap::cpret<desttyp,srctyp> bytecp(desttyp * zap_restr dest,srctyp const * zap_restr src,::zap::sz const num) noexcept { - ::zap_cpret const cpret = ::zap_cp(dest,src,num); - - return ::zap::cpret<desttyp,srctyp> {.dest = static_cast<desttyp *>(cpret.dest),.src = static_cast<srctyp *>(cpret.src),}; - } - - template<typename ltyp,typename rtyp> zap_attr_iln inline bool byteeq(ltyp const * lbuf,rtyp const * rbuf,::zap::sz const num) noexcept { - return ::zap_eq(lbuf,rbuf,num); - } - - template<typename typ> zap_attr_iln inline void bytefill(typ * dest,unsigned char const val,::zap::sz const num) noexcept { - ::zap_fill(dest,val,num); - } - - template<typename typ> zap_attr_iln inline typ * bytesrch(typ * buf,unsigned char const val,::zap::sz const num) noexcept { - return const_cast<typ *>(static_cast<::zap::remqual<typ> *>(::zap_srch(buf,val,num))); - } -} - -namespace zap { - template<typename typ> constexpr ::zap::cpret<typ,typ> cp(typ * zap_restr dest,typ const * zap_restr src,::zap::sz const num) noexcept { - zap_priv_ifnconsteval {return ::zap::bytecp(dest,src,num);} - - typ * const zap_restr stop = dest + num; - while (dest != stop) *dest++ = *src++; - - return ::zap::cpret<typ,typ> {.dest = dest,.src = const_cast<typ *>(src),}; - } - - template<typename typ> constexpr bool eq(typ const * lbuf,typ const * rbuf,::zap::sz const num) noexcept { - typ const * const stop = lbuf + num; - - while (lbuf != stop) if (*lbuf++ != *rbuf++) return false; - - return true; - } - - template<typename typ> constexpr void fill(typ * dest,typ const val,::zap::sz const num) noexcept { - typ * const stop = dest + num; - - while (dest != stop) *dest++ = val; - } - - template<typename typ> constexpr typ * srch(typ * buf,unsigned char const val,::zap::sz const num) noexcept { - typ const * const stop = buf + num; - - while (buf != stop) { - typ const * addr = buf++; - if (*addr == val) return addr; - } - - return nullptr; - } -} - -#endif |