summaryrefslogtreecommitdiff
path: root/zap/include
diff options
context:
space:
mode:
Diffstat (limited to 'zap/include')
-rw-r--r--zap/include/zap/bs.h52
-rw-r--r--zap/include/zap/mem.h4
-rw-r--r--zap/include/zap/str.h24
3 files changed, 77 insertions, 3 deletions
diff --git a/zap/include/zap/bs.h b/zap/include/zap/bs.h
index 78d09f9..3a1a1dd 100644
--- a/zap/include/zap/bs.h
+++ b/zap/include/zap/bs.h
@@ -96,7 +96,8 @@
zap_priv_cdecl
-#define zap_ver ((unsigned long)+0x18u)
+#define zap_ver ((unsigned long)+0x19u)
+#define zap_compatver ((unsigned long)+0x19u) // Programs expecting this version will still compile with the current version.
#define zap_nopos zap_maxvalsz
@@ -313,6 +314,55 @@ namespace zap {
}
namespace zap {
+ template<typename typ> constexpr auto ischrtyp =
+ ::zap::typeq<typ,char>
+ || ::zap::typeq<typ,char16_t>
+ || ::zap::typeq<typ,char32_t>
+#if __cpp_char8_t
+ || ::zap::typeq<typ,char8_t>
+#endif
+ || ::zap::typeq<typ,unsigned char>
+ || ::zap::typeq<typ,wchar_t>;
+
+ template<typename typ> constexpr auto isflttyp =
+ ::zap::typeq<typ,double>
+ || ::zap::typeq<typ,float>
+ || ::zap::typeq<typ,long double>
+#if __STDCPP_BFLOAT16_T__
+ || ::zap::typeq<typ,decltype (0x0.0p0bf16)>
+#endif
+#if __STDCPP_FLOAT128_T__
+ || ::zap::typeq<typ,decltype (0x0.0p0f16)>
+#endif
+#if __STDCPP_FLOAT16_T__
+ || ::zap::typeq<typ,decltype (0x0.0p0f32)>
+#endif
+#if __STDCPP_FLOAT32_T__
+ || ::zap::typeq<typ,decltype (0x0.0p0f64)>
+#endif
+#if __STDCPP_FLOAT64_T__
+ || ::zap::typeq<typ,decltype (0x0.0p0f128)>
+#endif
+ ;
+
+ template<typename typ> constexpr auto isinttyp =
+ ::zap::typeq<typ,int>
+ || ::zap::typeq<typ,long>
+ || ::zap::typeq<typ,long long>
+ || ::zap::typeq<typ,short>
+ || ::zap::typeq<typ,signed char>
+ || ::zap::typeq<typ,unsigned char>
+ || ::zap::typeq<typ,unsigned int>
+ || ::zap::typeq<typ,unsigned long>
+ || ::zap::typeq<typ,unsigned long long>
+ || ::zap::typeq<typ,unsigned short>;
+
+ template<typename typ> constexpr auto isarithtyp =
+ ::zap::isflttyp<typ>
+ || ::zap::isinttyp<typ>;
+}
+
+namespace zap {
using i8 = ::zap_i8;
using i01 = ::zap_i01;
using i02 = ::zap_i02;
diff --git a/zap/include/zap/mem.h b/zap/include/zap/mem.h
index 36f06b9..751a601 100644
--- a/zap/include/zap/mem.h
+++ b/zap/include/zap/mem.h
@@ -11,10 +11,10 @@
zap_priv_cdecl
-zap_priv_nothrw void zap_cp( void * zap_priv_restr dest,void const * zap_priv_restr src, zap_sz num);
+zap_priv_nothrw void * zap_cp( void * zap_priv_restr dest,void const * zap_priv_restr src, zap_sz num);
zap_priv_nothrw zap_i8 zap_eq( void const * lbuf,void const * rbuf,zap_sz num);
zap_priv_nothrw void zap_fill(void * dest,unsigned char val, zap_sz num);
-zap_priv_nothrw void * zap_srch(void const * buf, unsigned char val, zap_sz num);
+zap_priv_nothrw void * zap_srch(void const * buf, unsigned char val, zap_sz num);
zap_priv_cdeclend
diff --git a/zap/include/zap/str.h b/zap/include/zap/str.h
index 42519dc..c594ce4 100644
--- a/zap/include/zap/str.h
+++ b/zap/include/zap/str.h
@@ -46,4 +46,28 @@ zap_i8 zap_fmtlenus( unsigned short val,zap_i8 bs);
zap_priv_cdeclend
+#if __cplusplus
+
+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
+
#endif