summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Jensen2023-06-05 20:15:06 +0200
committerGabriel Jensen2023-06-05 20:15:06 +0200
commit18e345cb484f389c549a71d6e09feba20b3c6de1 (patch)
treeffe7ea8b828e6ed1fdcbc883b5bb75cfdc5d0a85
parent3d285c927d209770ab2dfb07bb10095afc55d130 (diff)
Update res.exp and opt.exp: Take variadic parameters; Add inheritable error type (that may be used for exceptions): err; Implement trp in inline assembly; Raise SIGTRAP on some hosted environments in trp; Fix error in ARM64 syscal comment; Add (C++98 compatible) metaprogramming class for special values: val; Rework arrays; Add function for moving memory sequences: mov;HEADmaster
-rw-r--r--CHANGELOG.txt9
-rw-r--r--test.cc61
-rw-r--r--zp/GNUmakefile87
-rw-r--r--zp/include/zp/det/mem.d/arr.ii48
-rw-r--r--zp/include/zp/det/mem.ii87
-rw-r--r--zp/include/zp/det/zp.ii8
-rw-r--r--zp/include/zp/mem86
-rw-r--r--zp/include/zp/mem.h3
-rw-r--r--zp/include/zp/prv/flt.h18
-rw-r--r--zp/include/zp/zp464
-rw-r--r--zp/include/zp/zp.h8
-rw-r--r--zp/source/amd64/zp/trp.s8
-rw-r--r--zp/source/any/mem/memcpy.c2
-rw-r--r--zp/source/any/zp/trp.c27
-rw-r--r--zp/source/arm64/zp/syscal.s2
15 files changed, 561 insertions, 357 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8c658c4..feab310 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -12,6 +12,15 @@
* Rename remqual to remcv;
* Fix nan and inf for qualified types;
+* Update res.exp and opt.exp: Take variadic parameters;
+* Add inheritable error type (that may be used for exceptions): err;
+* Implement trp in inline assembly;
+* Raise SIGTRAP on some hosted environments in trp;
+* Fix error in ARM64 syscal comment;
+* Add (C++98 compatible) metaprogramming class for special values: val;
+* Rework arrays;
+* Add function for moving memory sequences: mov;
+
# 1.1.1
* Fix res dtor calls;
diff --git a/test.cc b/test.cc
index 9255f40..ac5c636 100644
--- a/test.cc
+++ b/test.cc
@@ -91,12 +91,11 @@ static_assert(::zp::typequ<::zp::nulptrtyp,::std::nullptr_t>::val == true);
static_assert(::zp::bytelen == CHAR_BIT);
template<typename typtyp> constexpr static auto chktyp() noexcept -> bool {
- using ::zp::inf;
- using ::zp::nan;
using ::zp::nulptr;
using ::zp::typequ;
using typ = ::zp::typ<typtyp>;
+ using val = ::zp::val<typtyp>;
using numlim = ::std::numeric_limits<typtyp>;
if constexpr (!typequ<typename ::zp::remcv<typtyp>::typ,bool>::val && !typ::ischr) {static_assert(typ::isint == ::std::is_integral_v<typtyp>);}
@@ -107,11 +106,11 @@ template<typename typtyp> constexpr static auto chktyp() noexcept -> bool {
static_assert(typ::hassgn == numlim::is_signed);
- static_assert(typ::min == numlim::lowest());
- static_assert(typ::max == numlim::max());
+ static_assert(val::min() == numlim::lowest());
+ static_assert(val::max() == numlim::max());
if constexpr (typ::isflt) {
- static_assert(inf<typtyp>::val == numlim::infinity());
+ static_assert(val::inf() == numlim::infinity());
}
return true;
@@ -307,17 +306,17 @@ int main() {
chkeq(sizeof (f02),0x4u);
chkeq(sizeof (f04),0x8u);
- f02 = ::zp::nan<::zp::f02>::val;
- f04 = ::zp::nan<::zp::f04>::val;
+ f02 = ::zp::val<::zp::f02>::nan();
+ f04 = ::zp::val<::zp::f04>::nan();
chkeq(::zp::isnan(f02),true);
chkeq(::zp::isnan(f04),true);
- f02 = ::zp::inf<::zp::f02>::val;
- f04 = ::zp::inf<::zp::f04>::val;
+ f02 = ::zp::val<::zp::f02>::inf();
+ f04 = ::zp::val<::zp::f04>::inf();
- chkgt(f02,::zp::typ<::zp::f02>::max);
- chkgt(f04,::zp::typ<::zp::f04>::max);
+ chkgt(f02,::zp::val<::zp::f02>::max());
+ chkgt(f04,::zp::val<::zp::f04>::max());
}();
[&] {
@@ -483,45 +482,31 @@ int main() {
delete[] buf02;
}();
-#if false
- [&] {
- tst("boxes");
-
- ::zp::box<::zp::i8s,::std::allocator<::zp::i8s>> box0 = 0x4;
-
- chkeq(*box0,0x4);
-
- ::zp::box<::zp::i8s,::std::allocator<::zp::i8s>> const box1 = 0x0-box1;
-
- chkeq(*box1,-0x4);
- }();
-#endif
-
[&] {
tst("arrays");
- ::zp::arr<::zp::i8,::std::allocator<::zp::i8>> arr(0x8u);
+ auto arr0 = ::zp::arr<::zp::i8,::std::allocator<::zp::i8>>::alc(0x8u);
- chkeq(arr.len(),0x8u);
+ chkeq(arr0.len(),0x8u);
- arr[0x0] = 0x7Fu;
- arr[0x1] = 0x3Fu;
- arr[0x2] = 0x1Fu;
- arr[0x3] = 0x0Fu;
- arr[0x4] = 0x07u;
- arr[0x5] = 0x03u;
- arr[0x6] = 0x01u;
- arr[0x7] = 0x00u;
+ arr0[0x0] = 0x7Fu;
+ arr0[0x1] = 0x3Fu;
+ arr0[0x2] = 0x1Fu;
+ arr0[0x3] = 0x0Fu;
+ arr0[0x4] = 0x07u;
+ arr0[0x5] = 0x03u;
+ arr0[0x6] = 0x01u;
+ arr0[0x7] = 0x00u;
::zp::i8 prv = 0xFFu;
- for (::zp::i8 const val : arr) {
+ for (::zp::i8 const val : arr0) {
chkeq(val,static_cast<::zp::i8>(prv>>0x1u));
prv = val;
}
- arr.fil(0xFFu);
+ arr0.fil(0xFFu);
- for (::zp::i8 const val : arr) {
+ for (::zp::i8 const val : arr0) {
chkeq(val,0xFFu);
}
}();
diff --git a/zp/GNUmakefile b/zp/GNUmakefile
index cc89537..3b469a9 100644
--- a/zp/GNUmakefile
+++ b/zp/GNUmakefile
@@ -23,8 +23,6 @@ ifeq "$(stdcxx)" ""
stdcxx := c++98
endif
-OBJ_ZP_TRP := source/any/zp/trp.o
-
OBJ_MEM_MEMCPY := source/any/mem/memcpy.o
OBJ_MEM_MEMEQU := source/any/mem/memequ.o
OBJ_MEM_MEMFIL := source/any/mem/memfil.o
@@ -65,11 +63,11 @@ OBJ_STR_WSTRLEN := source/any/str/wstrlen.o
OBJ_STR_WSTRSRH := source/any/str/wstrsrh.o
OBJ_ZP_SYSCAL := source/any/zp/syscal.o
+OBJ_ZP_TRP := source/any/zp/trp.o
ifeq "$(tar)" "amd64"
OBJ_ZP_SYSCAL := source/amd64/zp/syscal.o
-OBJ_ZP_TRP := source/amd64/zp/trp.o
OBJ_MEM_MEMCPY := source/amd64/mem/memcpy.o
OBJ_MEM_MEMFIL := source/amd64/mem/memfil.o
@@ -146,51 +144,56 @@ LIB := libzp.a
endif
HDRS := \
- include/zp/mem \
- include/zp/mem.h \
- include/zp/mth \
- include/zp/mth.h \
- include/zp/str \
- include/zp/str.h \
- include/zp/zp \
- include/zp/zp.h \
- include/zp/det/mem.ii \
- include/zp/det/mth.ii \
- include/zp/det/str.ii \
- include/zp/det/zp.ii \
- include/zp/prv/arc.h \
- include/zp/prv/chr.h \
- include/zp/prv/flt.h \
- include/zp/prv/imp.h \
- include/zp/prv/int.h \
- include/zp/prv/std.h \
- include/zp/prv/sys.h \
- include-private/zp/prv/fmt \
+ include/zp/mem \
+ include/zp/mem.h \
+ include/zp/mth \
+ include/zp/mth.h \
+ include/zp/str \
+ include/zp/str.h \
+ include/zp/zp \
+ include/zp/zp.h \
+ include/zp/det/mem.ii \
+ include/zp/det/mth.ii \
+ include/zp/det/str.ii \
+ include/zp/det/zp.ii \
+ include/zp/det/mem.d/arr.ii \
+ include/zp/prv/arc.h \
+ include/zp/prv/chr.h \
+ include/zp/prv/flt.h \
+ include/zp/prv/imp.h \
+ include/zp/prv/int.h \
+ include/zp/prv/std.h \
+ include/zp/prv/sys.h \
+ include-private/zp/prv/fmt \
include-private/zp/prv/str
CFLAGS := \
- -Iinclude \
- -Iinclude-private \
- -Wall \
- -Wextra \
- -Wpedantic \
- -ffreestanding \
- -fshort-enums \
- -nostdlib \
- -pipe \
+ -Iinclude \
+ -Iinclude-private \
+ -Wall \
+ -Wextra \
+ -Wpedantic \
+ -ffreestanding \
+ -fno-strict-aliasing \
+ -fno-strict-overflow \
+ -fshort-enums \
+ -nostdlib \
+ -pipe \
-std=$(stdc)
CXXFLAGS := \
- -Iinclude \
- -Iinclude-private \
- -Wall \
- -Wextra \
- -Wpedantic \
- -ffreestanding \
- -fno-exceptions \
- -fshort-enums \
- -nostdlib \
- -pipe \
+ -Iinclude \
+ -Iinclude-private \
+ -Wall \
+ -Wextra \
+ -Wpedantic \
+ -ffreestanding \
+ -fno-exceptions \
+ -fno-strict-aliasing \
+ -fno-strict-overflow \
+ -fshort-enums \
+ -nostdlib \
+ -pipe \
-std=$(stdcxx)
ifeq "$(shrlib)" "true"
diff --git a/zp/include/zp/det/mem.d/arr.ii b/zp/include/zp/det/mem.d/arr.ii
new file mode 100644
index 0000000..2080bdd
--- /dev/null
+++ b/zp/include/zp/det/mem.d/arr.ii
@@ -0,0 +1,48 @@
+/*
+ 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>.
+*/
+
+template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> const& oth) : _alc(alctyp {}),_len(oth._len) {
+ this->_buf = this->_alc.allocate(this->_len);
+ ::zp::cpy(this->_buf,oth._buf,oth._len);
+}
+
+template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> && oth) : _alc(oth._alc),_buf(oth._buf),_len(oth._len) {oth._buf = ::zp::nulptr<typ>();}
+
+template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::~arr() noexcept(false) {
+ zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;}
+
+ for (typ * elm = this->begin();elm != this->end();++elm) {elm->~typ();} // Destroy the elements.
+
+ this->_alc.deallocate(this->_buf,this->_len);
+}
+
+template<typename typ,typename alctyp> template<typename... argtyp> auto ::zp::arr<typ,alctyp>::alc(::zp::siz const len,argtyp const&... arg) -> ::zp::arr<typ,alctyp> {
+ ::zp::arr<typ,alctyp> arr;
+
+ arr._len = len;
+ arr._buf = arr._alc.allocate(len);
+ zp_unlik (arr._buf == ::zp::nulptr<typ>()) {::zp::trp();} // If the allocator does NOT throw exceptions.
+
+ for (typ * elm = arr.begin();elm != arr.end();++elm) {*elm = typ {arg...};} // Construct the elements.
+
+ return arr;
+}
+
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::oky() const noexcept -> bool {return this->_buf == ::zp::nulptr<typ>();}
+
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::len() const noexcept -> ::zp::siz {return this->_len;}
+
+template<typename typ,typename alctyp> template<typename valtyp> ::zp::siz ::zp::arr<typ,alctyp>::fil(valtyp const& val) {return static_cast<::zp::siz>(::zp::fil(this->_buf,val,this->_len)-this->_buf);}
+
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::begin() noexcept -> typ * {return this->_buf;}
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::begin() const noexcept -> typ const* {return this->_buf;}
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::end() noexcept -> typ * {return this->_buf+this->_len;}
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::end() const noexcept -> typ const* {return this->_buf+this->_len;}
+
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) noexcept -> typ & {zp_unlik (off < 0x0) {::zp::trp();} return this->_buf[off];}
+template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) const noexcept -> typ const& {zp_unlik (off < 0x0) {::zp::trp();} return this->_buf[off];}
+
+template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::arr() : _alc(alctyp {}) {}
diff --git a/zp/include/zp/det/mem.ii b/zp/include/zp/det/mem.ii
index 391f4e1..eb2138b 100644
--- a/zp/include/zp/det/mem.ii
+++ b/zp/include/zp/det/mem.ii
@@ -4,82 +4,8 @@
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
-#if zp_std_cxx11 && false
-template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::box(typ const& val) : _alc(alctyp {}) {
- this->_obj.buf = this->_alc(0x1);
- *this->_obj.buf = val;
- this->_obj.cnt = 0x0u;
-}
-
-template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::box(typ && val) : _alc(alctyp {}) {
- this->_obj.buf = this->_alc.allocate(0x1u);
- *this->_obj.buf = val;
- *this->_obj.cnt = 0x0u;
-}
-
-template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::~box() noexcept(false) {
- this->_buf->~typ();
- this->_alc.deallocate(this->_buf,0x1u);
-}
-
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator =(typ const& val) -> ::zp::box<typ,alctyp> & {*this->_obj.buf = val;return *this;}
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator =(typ && val) -> ::zp::box<typ,alctyp> & {*this->_obj.buf = val;return *this;}
-
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator *() noexcept -> typ & {return *this->_buf;}
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator *() const noexcept -> typ const& {return *this->_buf;}
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator &() noexcept -> typ * {return this->_buf;}
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator &() const noexcept -> typ const* {return this->_buf;}
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator ->() noexcept -> typ * {return *this->_buf;}
-template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator ->() const noexcept -> typ const* {return *this->_buf;}
-
-template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::operator typ() const noexcept {return *this->_buf;}
-#endif
-
-#if zp_std_cxx11
-template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr() : _alc(alctyp()) {}
-
-/*template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> & oth) : _alc(alctyp()),_buf(this->_alc.allocate(len)),_len(oth._len) {
-
- zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;} // Allocation failed.
-
- ::zp::cpy(this->_buf,oth._buf,oth._len);
-}*/
-
-template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::siz const len) : _alc(alctyp {}) {
- this->_buf = this->_alc.allocate(len);
- this->_len = len;
-}
-
#if zp_std_cxx11
-template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> && oth) : _alc(oth._alc),_buf(oth._buf),_len(oth._len) {oth._buf = ::zp::nulptr<typ>();}
-#endif
-
-template<typename typ,typename alctyp> zp_nothw zp::arr<typ,alctyp>::~arr() {
- zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;}
- this->_alc.deallocate(this->_buf,this->_len);
-}
-
-template<typename typ,typename alctyp> zp_nothw bool zp::arr<typ,alctyp>::oky() const {return this->_buf == ::zp::nulptr<typ>();}
-
-template<typename typ,typename alctyp> zp_nothw ::zp::siz zp::arr<typ,alctyp>::len() const {return this->_len;}
-
-template<typename typ,typename alctyp> bool zp::arr<typ,alctyp>::alc(::zp::siz const len) {
- this->_len = len;
- this->_buf = this->_alc(len);
-
- zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return true;} // If the allocator does NOT throw exceptions.
- return false;
-}
-
-template<typename typ,typename alctyp> template<typename valtyp> ::zp::siz zp::arr<typ,alctyp>::fil(valtyp const& val) {return static_cast<::zp::siz>(::zp::fil(this->_buf,val,this->_len)-this->_buf);}
-
-template<typename typ,typename alctyp> typ * zp::arr<typ,alctyp>::begin() {return this->_buf;}
-template<typename typ,typename alctyp> typ const* zp::arr<typ,alctyp>::begin() const {return this->_buf;}
-template<typename typ,typename alctyp> typ * zp::arr<typ,alctyp>::end() {return this->_buf+this->_len;}
-template<typename typ,typename alctyp> typ const* zp::arr<typ,alctyp>::end() const {return this->_buf+this->_len;}
-
-template<typename typ,typename alctyp> typ & zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) {return this->_buf[off];}
-template<typename typ,typename alctyp> typ const& zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) const {return this->_buf[off];}
+#include <zp/det/mem.d/arr.ii>
#endif
template<typename dsttyp,typename srctyp> zp_nothw inline ::zp::cpyres<dsttyp,srctyp> zp::memcpy(dsttyp * dst,srctyp const* src,::zp::siz const num) {
@@ -94,7 +20,7 @@ template<typename dsttyp,typename srctyp> zp_nothw inline ::zp::cpyres<dsttyp,sr
}
template<typename ltyp,typename rtyp> ::zp::cpyres<ltyp,rtyp> zp::cpy(ltyp * dst,rtyp * src,::zp::siz const num) {
- ltyp * const stp = dst+num;
+ ltyp * const stp = dst+num;
while (dst != stp) {*dst++ = *src++;}
::zp::cpyres<ltyp,rtyp> res;
@@ -131,3 +57,12 @@ template<typename buftyp,typename valtyp> buftyp * zp::srh(buftyp * buf,valtyp &
return ::zp::nulptr<buftyp>();
}
+
+#if zp_std_cxx11
+template<typename ltyp,typename rtyp> ::zp::cpyres<ltyp,rtyp> zp::mov(ltyp * dst,rtyp * src,::zp::siz const num) {
+ ltyp * const stp = dst+num;
+ while (dst != stp) {*dst++ = ::zp::fwd(*src++);}
+
+ return ::zp::cpyres<ltyp,rtyp> {dst,src};
+}
+#endif
diff --git a/zp/include/zp/det/zp.ii b/zp/include/zp/det/zp.ii
index f044390..dfa1491 100644
--- a/zp/include/zp/det/zp.ii
+++ b/zp/include/zp/det/zp.ii
@@ -36,9 +36,9 @@ template<typename typ> auto ::zp::opt<typ>::chk() const noexcept -> bool {return
template<typename typ> auto ::zp::opt<typ>::val() const noexcept -> typ const& {return this->_val;}
-template<typename typ> template<typename funtyp,typename msgtyp> auto ::zp::opt<typ>::exp(funtyp const& fun,msgtyp const& msg) const noexcept -> typ const& {
+template<typename typ> template<typename funtyp,typename... argtyp> auto ::zp::opt<typ>::exp(funtyp const& fun,argtyp const&... arg) const noexcept -> typ const& {
zp_unlik (!this->_hasval) {
- fun(msg);
+ fun(arg...);
::zp::unrch();
}
@@ -126,9 +126,9 @@ template<typename okytyp,typename errtyp> auto ::zp::res<okytyp,errtyp>::getoky(
template<typename okytyp,typename errtyp> auto ::zp::res<okytyp,errtyp>::geterr() const noexcept -> errtyp const& {return this->_errval;}
-template<typename okytyp,typename errtyp> template<typename funtyp,typename msgtyp> auto ::zp::res<okytyp,errtyp>::exp(funtyp const& fun,msgtyp const& msg) const noexcept -> okytyp const& {
+template<typename okytyp,typename errtyp> template<typename funtyp,typename... argtyp> auto ::zp::res<okytyp,errtyp>::exp(funtyp const& fun,argtyp const&... arg) const noexcept -> okytyp const& {
zp_unlik (!this->_hasoky) {
- fun(msg);
+ fun(arg...);
::zp::unrch();
}
diff --git a/zp/include/zp/mem b/zp/include/zp/mem
index d081dfd..3ee44b9 100644
--- a/zp/include/zp/mem
+++ b/zp/include/zp/mem
@@ -11,82 +11,46 @@
#include <zp/mem.h>
namespace zp {
+ struct alcerr : public err {};
+
template<typename dsttyp,typename srctyp> struct cpyres {
dsttyp * dst;
srctyp * src;
};
-#if zp_std_cxx11 && false
- namespace det {
- template<typename typ,typename alctyp> struct boxobj {
- alctyp alc
- ::zp::i02 cnt;
- typ * buf;
- };
- }
-
- template<typename typ,typename alctyp> class box {
- public:
- box() = delete;
- box(box<typ,alctyp> const& oth);
- box(box<typ,alctyp> && oth);
- box(typ const& val);
- box(typ && val);
-
- ~box() noexcept(false);
-
- auto operator =(typ const& val) -> ::zp::box<typ,alctyp> &;
- auto operator =(typ && val) -> ::zp::box<typ,alctyp> &;
-
- auto operator *() noexcept -> typ &;
- auto operator *() const noexcept -> typ const&;
- auto operator &() noexcept -> typ *;
- auto operator &() const noexcept -> typ const*;
- auto operator ->() noexcept -> typ *;
- auto operator ->() const noexcept -> typ const*;
-
- operator typ() const noexcept;
-
- private:
- alctyp _alc;
- boxobj<typ,alctyp> _obj;
- };
-#endif
-
#if zp_std_cxx11
template<typename typ,typename alctyp> class arr {
public:
- zp_nothw arr();
- arr(::zp::arr<typ,alctyp> & oth);
- explicit arr(::zp::siz len);
-#if zp_std_cxx11
- zp_nothw arr(::zp::arr<typ,alctyp> && oth);
-#endif
+ arr(::zp::arr<typ,alctyp> const& oth);
+ arr(::zp::arr<typ,alctyp> && oth);
- zp_nothw ~arr();
+ ~arr() noexcept(false);
- zp_nothw bool oky() const;
+ template<typename... argtyp> static auto alc(::zp::siz len,argtyp const&... arg) -> ::zp::arr<typ,alctyp>;
- zp_nothw typ * ptr();
- zp_nothw typ const* ptr() const;
- zp_nothw ::zp::siz len() const;
+ auto oky() const noexcept -> bool;
- bool alc(::zp::siz len);
+ auto ptr() noexcept -> typ *;
+ auto ptr() const noexcept -> typ const*;
+ auto len() const noexcept -> ::zp::siz;
- template<typename valtyp> ::zp::siz fil(valtyp const& val);
+ template<typename othval,typename othalc> auto cpy(::zp::arr<othval,othalc> const& oth) -> ::zp::siz;
+ template<typename valtyp> auto fil(valtyp const& val) -> ::zp::siz;
- zp_nothw typ * begin();
- zp_nothw typ const* begin() const;
- zp_nothw typ * end();
- zp_nothw typ const* end() const;
+ auto begin() noexcept -> typ *;
+ auto begin() const noexcept -> typ const*;
+ auto end() noexcept -> typ *;
+ auto end() const noexcept -> typ const*;
- zp_nothw typ & operator [](::zp::ptrdif off);
- zp_nothw typ const& operator [](::zp::ptrdif off) const;
+ auto operator [](::zp::ptrdif off) noexcept -> typ &; // Always UB if (off<0).
+ auto operator [](::zp::ptrdif off) const noexcept -> typ const&;
private:
alctyp _alc;
typ * _buf;
::zp::siz _len;
+
+ arr();
};
#endif
@@ -96,12 +60,12 @@ namespace zp {
template<typename typ> zp_useres zp_nothw zp_iln inline typ * memsrh(typ * zp_prv_rsr buf, char unsigned val, ::zp::siz const num) {return static_cast<typ *>(::zp_memsrh(buf,val,num));}
template<typename typ> zp_useres zp_nothw zp_iln inline typ const* memsrh(typ const* zp_prv_rsr buf, char unsigned val, ::zp::siz const num) {return const_cast<typ const*>(static_cast<typ *>(::zp_memsrh(buf,val,num)));}
- template<typename ltyp, typename rtyp> zp_nothw ::zp::cpyres<ltyp,rtyp> cpy(ltyp * dst, rtyp * src, ::zp::siz num);
- template<typename ltyp, typename rtyp> zp_nothw bool equ(ltyp * lbuf,rtyp * rbuf,::zp::siz num);
- template<typename buftyp,typename valtyp> zp_nothw buftyp * fil(buftyp * buf, valtyp & val, ::zp::siz num);
- template<typename buftyp,typename valtyp> zp_nothw buftyp * srh(buftyp * buf, valtyp & val, ::zp::siz num);
+ template<typename ltyp, typename rtyp> ::zp::cpyres<ltyp,rtyp> cpy(ltyp * dst, rtyp * src, ::zp::siz num);
+ template<typename ltyp, typename rtyp> bool equ(ltyp * lbuf,rtyp * rbuf,::zp::siz num);
+ template<typename buftyp,typename valtyp> buftyp * fil(buftyp * buf, valtyp & val, ::zp::siz num);
+ template<typename buftyp,typename valtyp> buftyp * srh(buftyp * buf, valtyp & val, ::zp::siz num);
#if zp_std_cxx11
- template<typename ltyp, typename rtyp> zp_nothw ::zp::cpyres<ltyp,rtyp> cpy(ltyp * dst, rtyp * src, ::zp::siz num); // Identical to cpy except that all values are passed to fwd firstly.
+ template<typename ltyp, typename rtyp> ::zp::cpyres<ltyp,rtyp> mov(ltyp * dst, rtyp * src, ::zp::siz num); // Identical to cpy except that all values are passed to fwd firstly.
#endif
}
diff --git a/zp/include/zp/mem.h b/zp/include/zp/mem.h
index c2aa5c9..771ecc0 100644
--- a/zp/include/zp/mem.h
+++ b/zp/include/zp/mem.h
@@ -16,6 +16,9 @@ typedef struct {
void * src;
} zp_cpyres;
+zp_nothw zp_i02 zp_prv_inc02(zp_i02 * ptr);
+zp_nothw zp_i02 zp_prv_dec02(zp_i02 * ptr);
+
zp_nothw zp_cpyres zp_memcpy(void * zp_prv_rsr dst, void const* zp_prv_rsr src, zp_siz num);
zp_nothw zp_useres bool zp_memequ(void const* zp_prv_rsr lbuf,void const* zp_prv_rsr rbuf,zp_siz num);
zp_nothw void * zp_memfil(void * zp_prv_rsr dst, char unsigned val, zp_siz num);
diff --git a/zp/include/zp/prv/flt.h b/zp/include/zp/prv/flt.h
index 01c68b4..a8c8b42 100644
--- a/zp/include/zp/prv/flt.h
+++ b/zp/include/zp/prv/flt.h
@@ -76,14 +76,6 @@
#endif
-#define zp_minvalf02 zp_minvalf
-#define zp_maxvalf02 zp_maxvalf
-typedef float zp_f02;
-
-#define zp_minvalf04 zp_minvald
-#define zp_maxvalf04 zp_maxvald
-typedef double zp_f04;
-
#if zp_prv_hasbltin(__builtin_nan)
#define zp_nand (__builtin_nan(""))
#else
@@ -116,8 +108,14 @@ typedef double zp_f04;
#define zp_inff (zp_maxvalf)
#endif
+#define zp_minvalf02 zp_minvalf
+#define zp_maxvalf02 zp_maxvalf
+typedef float zp_f02;
#define zp_nanf02 (zp_nanf)
-#define zp_nanf04 (zp_nand)
-
#define zp_inff02 (zp_inff)
+
+#define zp_minvalf04 zp_minvald
+#define zp_maxvalf04 zp_maxvald
+typedef double zp_f04;
+#define zp_nanf04 (zp_nand)
#define zp_inff04 (zp_infd)
diff --git a/zp/include/zp/zp b/zp/include/zp/zp
index f95d4a0..2164b14 100644
--- a/zp/include/zp/zp
+++ b/zp/include/zp/zp
@@ -62,6 +62,8 @@ namespace zp {
using nulptrtyp = ::zp_nulptrtyp;
#endif
+ struct err {};
+
#if zp_std_cxx11
template<typename typtyp> struct typ {
constexpr static bool isari = false;
@@ -70,9 +72,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = false;
-
- constexpr static typtyp min = typtyp {};
- constexpr static typtyp max = typtyp {};
};
template<typename typtyp> struct typ<typtyp const> {
@@ -82,9 +81,6 @@ namespace zp {
constexpr static bool ischr = typ<typtyp>::ischr;
constexpr static bool hassgn = typ<typtyp>::hassgn;
-
- constexpr static typtyp min = typ<typtyp>::min;
- constexpr static typtyp max = typ<typtyp>::max;
};
template<typename typtyp> struct typ<typtyp volatile> {
@@ -94,9 +90,6 @@ namespace zp {
constexpr static bool ischr = typ<typtyp>::ischr;
constexpr static bool hassgn = typ<typtyp>::hassgn;
-
- constexpr static typtyp min = typ<typtyp>::min;
- constexpr static typtyp max = typ<typtyp>::max;
};
template<typename typtyp> struct typ<typtyp const volatile> {
@@ -106,9 +99,6 @@ namespace zp {
constexpr static bool ischr = typ<typtyp>::ischr;
constexpr static bool hassgn = typ<typtyp>::hassgn;
-
- constexpr static typtyp min = typ<typtyp>::min;
- constexpr static typtyp max = typ<typtyp>::max;
};
template<> struct typ<bool> {
@@ -118,9 +108,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = false;
-
- constexpr static bool min = false;
- constexpr static bool max = true;
};
template<> struct typ<char> {
@@ -130,9 +117,6 @@ namespace zp {
constexpr static bool ischr = true;
constexpr static bool hassgn = !zp_uchr;
-
- constexpr static char min = zp_minvalc;
- constexpr static char max = zp_maxvalc;
};
template<> struct typ<char signed> {
@@ -142,9 +126,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static char signed min = zp_minvalcs;
- constexpr static char signed max = zp_maxvalcs;
};
template<> struct typ<char unsigned> {
@@ -154,9 +135,6 @@ namespace zp {
constexpr static bool ischr = true;
constexpr static bool hassgn = false;
-
- constexpr static char unsigned min = zp_minvalcu;
- constexpr static char unsigned max = zp_maxvalcu;
};
template<> struct typ<char16_t> {
@@ -166,9 +144,6 @@ namespace zp {
constexpr static bool ischr = true;
constexpr static bool hassgn = false;
-
- constexpr static char16_t min = zp_minvalc01;
- constexpr static char16_t max = zp_maxvalc01;
};
template<> struct typ<char32_t> {
@@ -178,9 +153,6 @@ namespace zp {
constexpr static bool ischr = true;
constexpr static bool hassgn = false;
-
- constexpr static char32_t min = zp_minvalc02;
- constexpr static char32_t max = zp_maxvalc02;
};
#if zp_std_cxx20
@@ -191,9 +163,6 @@ namespace zp {
constexpr static bool ischr = true;
constexpr static bool hassgn = false;
-
- constexpr static char8_t min = zp_minvalc8;
- constexpr static char8_t max = zp_maxvalc8;
};
#endif // C++20
@@ -204,9 +173,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static double min = zp_minvald;
- constexpr static double max = zp_maxvald;
};
template<> struct typ<double long> {
@@ -216,9 +182,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static double long min = zp_minvaldl;
- constexpr static double long max = zp_maxvaldl;
};
template<> struct typ<float> {
@@ -228,9 +191,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static float min = zp_minvalf;
- constexpr static float max = zp_maxvalf;
};
#if __STDCPP_BFLOAT16_T__
@@ -241,11 +201,8 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static decltype (0.0bf16) min = 0.0bf16;
- constexpr static decltype (0.0bf16) max = 0.0bf16;
};
-#endif
+#endif // bfloat16_t
#if __STDCPP_FLOAT128_T__
template<> struct typ<decltype (0.0f128)> {
@@ -255,11 +212,8 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static decltype (0.0f128) min = -1.189731495357231765085759326628007016196469052641694045529698884212163579755312392324974012848462073525902033564749126859755265433573804462672698751945261490853461958725021262845865799405404493574681566096686172574953791792292256220777095858112702436475442537092608935138247345677279593806773692330094615746119725784172889892521939920757654204864565673356452247278152288867700638935595456496699511441752909606878513250948311396886100526833092128683974752192266386791880873694343077348155564101669971138512786874753496996549221727686770196551512812712488289469952298031867469924683981576664562667786719061499639630341657098305425237220876664630087808767256182803220212219924852375903049520911395910918921205273496768588119030111593018789368039232011671404175845108854706965215605777113516257404818817695075025715299705916714352103671782759119316034498392169720631800164034124698918142227577300459309880454715179606299895507583075851195185857971173167676966057998899352631885417716295302014668802384075846036226606480142977595407135050379808649130157164024060311786908796372510335873512774795275748595417572920936651398752709055215663939505589207804914540432978557623565645991208599669097180808881920063722771431218489011922209679053545963628417326002439732802939524313786668514027381434321036636571171670423586472759561231970793967839279147282720195377060602122638457883204809341717526809639253539447730280863675704796054050525162959099932535265586464682793821550087166946662209865086040990507131145474267411042839542322762994938759613112743837192839682676257555388372814490845395747128162065871588219108887240116651361962050800029176299938826082417547516732269930473133261258921845516815235455354310458114528303607394526100730578774092094736822286015459361126642549541799645333882549670764145955017051330800061253865140180153211929361456500343514792890205532021760061882232615736553377294980974059590520187961459799386741513028505934410453603480192383349321115171811051004108592830991811382552909064873029533418691087118107895004426881765865961841419267486232005929789956207494587649901662172318722999484512325826087031561936383689740686505279775296789331613683822798597040651600524129025149894873153196942095056670847466927644812596506700129443579512479230621373978088731257089799622902183824105412930483065603459863120371744282301377070153823878609951218937542956964157950988060608985782910656238116142203574104757451828170804875257446204128348513829082731722364189380493588338947664370623279820755831646205417488393062838201789547219543194450902113699925965376908192792152122212824578879336506875288617303469517112245451315447164280392523574962804175375927948971096983905242318797695347043690474223813266505639761164438844266531364626851219633994434154098562127395936184421821444273431534507860161614287022720984061569660333372788241037131538077377480152670583257920535569973318188112685673318997967497786786001251403873023920127717626858627038170562807276699687356274072773403132694104831615879354395811585825112837841563222761623334459188131537882355732483030085976890382969734476214593428191212717141333047577867552218517431064848760373196290310124466145087078377140528533048684204278799596652514009368964527494988719996088230065668196236298805733689960371306226158464997243490564472254071897564144128539839986096045563264771285585066304177995720101744844387158329767375560416207800878830072072413908657855667239546369357775781344288195989176313356856417845434232814886744226746707066979755577121788798468777700116472954103621810567107869855646414713502627836321256957407217461738363552424248762436478085351810995749293238174081331905048144612700905541425702220302537611494824228765324577933778519818778697340282580912780674979058938062556856001076057705982166686824756037569615760497619819482052758118532729333127733603742149847001463931981340719681330844408263017545241644293372483217234561694263937855759294448662979095419227451801588425977869694026601427919655168415895923043115191751872713346095752634608254475988154162254952597853199039645883742199236387610395830948074365988397707849632252080920941206268114832425403540515474312327876180802357701527842702008781378306569508588571830140611098042683009530862797403015355464377406249853964481000402231771665700893607521804084523668568649103258862666293372472441435563520595461701042390500795615834505944837326652542467444364861499184275097485253621979537504128523848241127715641240965261646703516395599407360083455079665191393229410544185167999099787655424462558900874388405649169453726739312260234815543297842308646072190147948072928456725835039546121182133640777769925841807579051735838823112759622714067509669913645288281894558925612972425252452248453502562347348900936766966136332741088135837550717443838484760651019872222926016920811114616937143207743488504602012776364256746872315205952601072228970686460932435222754496341763535189105548847634608972381760403137363968e+4932f128;
- constexpr static decltype (0.0f128) max = +1.189731495357231765085759326628007016196469052641694045529698884212163579755312392324974012848462073525902033564749126859755265433573804462672698751945261490853461958725021262845865799405404493574681566096686172574953791792292256220777095858112702436475442537092608935138247345677279593806773692330094615746119725784172889892521939920757654204864565673356452247278152288867700638935595456496699511441752909606878513250948311396886100526833092128683974752192266386791880873694343077348155564101669971138512786874753496996549221727686770196551512812712488289469952298031867469924683981576664562667786719061499639630341657098305425237220876664630087808767256182803220212219924852375903049520911395910918921205273496768588119030111593018789368039232011671404175845108854706965215605777113516257404818817695075025715299705916714352103671782759119316034498392169720631800164034124698918142227577300459309880454715179606299895507583075851195185857971173167676966057998899352631885417716295302014668802384075846036226606480142977595407135050379808649130157164024060311786908796372510335873512774795275748595417572920936651398752709055215663939505589207804914540432978557623565645991208599669097180808881920063722771431218489011922209679053545963628417326002439732802939524313786668514027381434321036636571171670423586472759561231970793967839279147282720195377060602122638457883204809341717526809639253539447730280863675704796054050525162959099932535265586464682793821550087166946662209865086040990507131145474267411042839542322762994938759613112743837192839682676257555388372814490845395747128162065871588219108887240116651361962050800029176299938826082417547516732269930473133261258921845516815235455354310458114528303607394526100730578774092094736822286015459361126642549541799645333882549670764145955017051330800061253865140180153211929361456500343514792890205532021760061882232615736553377294980974059590520187961459799386741513028505934410453603480192383349321115171811051004108592830991811382552909064873029533418691087118107895004426881765865961841419267486232005929789956207494587649901662172318722999484512325826087031561936383689740686505279775296789331613683822798597040651600524129025149894873153196942095056670847466927644812596506700129443579512479230621373978088731257089799622902183824105412930483065603459863120371744282301377070153823878609951218937542956964157950988060608985782910656238116142203574104757451828170804875257446204128348513829082731722364189380493588338947664370623279820755831646205417488393062838201789547219543194450902113699925965376908192792152122212824578879336506875288617303469517112245451315447164280392523574962804175375927948971096983905242318797695347043690474223813266505639761164438844266531364626851219633994434154098562127395936184421821444273431534507860161614287022720984061569660333372788241037131538077377480152670583257920535569973318188112685673318997967497786786001251403873023920127717626858627038170562807276699687356274072773403132694104831615879354395811585825112837841563222761623334459188131537882355732483030085976890382969734476214593428191212717141333047577867552218517431064848760373196290310124466145087078377140528533048684204278799596652514009368964527494988719996088230065668196236298805733689960371306226158464997243490564472254071897564144128539839986096045563264771285585066304177995720101744844387158329767375560416207800878830072072413908657855667239546369357775781344288195989176313356856417845434232814886744226746707066979755577121788798468777700116472954103621810567107869855646414713502627836321256957407217461738363552424248762436478085351810995749293238174081331905048144612700905541425702220302537611494824228765324577933778519818778697340282580912780674979058938062556856001076057705982166686824756037569615760497619819482052758118532729333127733603742149847001463931981340719681330844408263017545241644293372483217234561694263937855759294448662979095419227451801588425977869694026601427919655168415895923043115191751872713346095752634608254475988154162254952597853199039645883742199236387610395830948074365988397707849632252080920941206268114832425403540515474312327876180802357701527842702008781378306569508588571830140611098042683009530862797403015355464377406249853964481000402231771665700893607521804084523668568649103258862666293372472441435563520595461701042390500795615834505944837326652542467444364861499184275097485253621979537504128523848241127715641240965261646703516395599407360083455079665191393229410544185167999099787655424462558900874388405649169453726739312260234815543297842308646072190147948072928456725835039546121182133640777769925841807579051735838823112759622714067509669913645288281894558925612972425252452248453502562347348900936766966136332741088135837550717443838484760651019872222926016920811114616937143207743488504602012776364256746872315205952601072228970686460932435222754496341763535189105548847634608972381760403137363968e+4932f128;
};
-#endif
+#endif // float128_t
#if __STDCPP_FLOAT32_T__
template<> struct typ<decltype (0.0f32)> {
@@ -269,11 +223,8 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static decltype (0.0f32) min = -3.40282346638528859811704183484516925440e+38f32;
- constexpr static decltype (0.0f32) max = +3.40282346638528859811704183484516925440e+38f32;
};
-#endif
+#endif // float32_t
#if __STDCPP_FLOAT64_T__
template<> struct typ<decltype (0.0f64)> {
@@ -283,11 +234,8 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static decltype (0.0f64) min = -1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e+308f64;
- constexpr static decltype (0.0f64) max = +1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e+308f64;
};
-#endif
+#endif // float64_t
template<> struct typ<int> {
constexpr static bool isari = true;
@@ -296,9 +244,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static int min = zp_minvali;
- constexpr static int max = zp_maxvali;
};
template<> struct typ<int long> {
@@ -308,9 +253,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static int long min = zp_minvalil;
- constexpr static int long max = zp_maxvalil;
};
template<> struct typ<int long long> {
@@ -320,9 +262,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static int long long min = zp_minvalill;
- constexpr static int long long max = zp_maxvalill;
};
template<> struct typ<int long long unsigned> {
@@ -332,9 +271,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = false;
-
- constexpr static int long long unsigned min = zp_minvalillu;
- constexpr static int long long unsigned max = zp_maxvalillu;
};
template<> struct typ<int long unsigned> {
@@ -344,9 +280,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = false;
-
- constexpr static int long unsigned min = zp_minvalilu;
- constexpr static int long unsigned max = zp_maxvalilu;
};
template<> struct typ<int short> {
@@ -356,9 +289,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = true;
-
- constexpr static int short min = zp_minvalis;
- constexpr static int short max = zp_maxvalis;
};
template<> struct typ<int short unsigned> {
@@ -368,9 +298,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = false;
-
- constexpr static int short unsigned min = zp_minvalisu;
- constexpr static int short unsigned max = zp_maxvalisu;
};
template<> struct typ<int unsigned> {
@@ -380,9 +307,6 @@ namespace zp {
constexpr static bool ischr = false;
constexpr static bool hassgn = false;
-
- constexpr static int unsigned min = zp_minvaliu;
- constexpr static int unsigned max = zp_maxvaliu;
};
template<> struct typ<wchar_t> {
@@ -392,9 +316,6 @@ namespace zp {
constexpr static bool ischr = true;
constexpr static bool hassgn = !zp_uwchr;
-
- constexpr static wchar_t min = zp_minvalw;
- constexpr static wchar_t max = zp_maxvalw;
};
#endif
@@ -406,6 +327,349 @@ namespace zp {
#endif
#if zp_std_cxx11
+ namespace det {
+ namespace cxx11 {
+ template<typename typ> struct val {
+ constexpr static auto min() noexcept -> typ {return typ {};}
+ constexpr static auto max() noexcept -> typ {return typ {};}
+
+ constexpr static auto nan() noexcept -> typ {return typ {};}
+ constexpr static auto inf() noexcept -> typ {return typ {};}
+ };
+
+ template<typename typ> struct val<typ const> {
+ constexpr static auto min() noexcept -> typ {return ::zp::det::cxx11::val<typ>::min();}
+ constexpr static auto max() noexcept -> typ {return ::zp::det::cxx11::val<typ>::max();}
+
+ constexpr static auto nan() noexcept -> typ {return ::zp::det::cxx11::val<typ>::nan();;}
+ constexpr static auto inf() noexcept -> typ {return ::zp::det::cxx11::val<typ>::inf();;}
+ };
+
+ template<typename typ> struct val<typ volatile> {
+ constexpr static auto min() noexcept -> typ {return ::zp::det::cxx11::val<typ>::min();}
+ constexpr static auto max() noexcept -> typ {return ::zp::det::cxx11::val<typ>::max();}
+
+ constexpr static auto nan() noexcept -> typ {return ::zp::det::cxx11::val<typ>::nan();;}
+ constexpr static auto inf() noexcept -> typ {return ::zp::det::cxx11::val<typ>::inf();;}
+ };
+
+ template<typename typ> struct val<typ const volatile> {
+ constexpr static auto min() noexcept -> typ {return ::zp::det::cxx11::val<typ>::min();}
+ constexpr static auto max() noexcept -> typ {return ::zp::det::cxx11::val<typ>::max();}
+
+ constexpr static auto nan() noexcept -> typ {return ::zp::det::cxx11::val<typ>::nan();;}
+ constexpr static auto inf() noexcept -> typ {return ::zp::det::cxx11::val<typ>::inf();;}
+ };
+
+ template<> struct val<bool> {
+ constexpr static auto min() noexcept -> bool {return false;}
+ constexpr static auto max() noexcept -> bool {return true;}
+
+ constexpr static auto nan() noexcept -> bool {return false;}
+ constexpr static auto inf() noexcept -> bool {return ::zp::det::cxx11::val<bool>::max();}
+ };
+
+ template<> struct val<char> {
+ constexpr static auto min() noexcept -> char {return zp_minvalc;}
+ constexpr static auto max() noexcept -> char {return zp_maxvalc;}
+
+ constexpr static auto nan() noexcept -> char {return '\x00';}
+ constexpr static auto inf() noexcept -> char {return ::zp::det::cxx11::val<char>::max();}
+ };
+
+ template<> struct val<char signed> {
+ constexpr static auto min() noexcept -> char signed {return zp_minvalcs;}
+ constexpr static auto max() noexcept -> char signed {return zp_maxvalcs;}
+
+ constexpr static auto nan() noexcept -> char signed {return 0x0;}
+ constexpr static auto inf() noexcept -> char signed {return ::zp::det::cxx11::val<char signed>::max();}
+ };
+
+ template<> struct val<char unsigned> {
+ constexpr static auto min() noexcept -> char unsigned {return zp_minvalcu;}
+ constexpr static auto max() noexcept -> char unsigned {return zp_maxvalcu;}
+
+ constexpr static auto nan() noexcept -> char unsigned {return 0x0u;}
+ constexpr static auto inf() noexcept -> char unsigned {return ::zp::det::cxx11::val<char unsigned>::max();}
+ };
+
+ template<> struct val<char16_t> {
+ constexpr static auto min() noexcept -> char16_t {return zp_minvalc01;}
+ constexpr static auto max() noexcept -> char16_t {return zp_maxvalc01;}
+
+ constexpr static auto nan() noexcept -> char16_t {return u'\x00';}
+ constexpr static auto inf() noexcept -> char16_t {return ::zp::det::cxx11::val<char16_t>::max();}
+ };
+
+ template<> struct val<char32_t> {
+ constexpr static auto min() noexcept -> char32_t {return zp_minvalc02;}
+ constexpr static auto max() noexcept -> char32_t {return zp_maxvalc02;}
+
+
+ constexpr static auto nan() noexcept -> char32_t {return U'\x00';}
+ constexpr static auto inf() noexcept -> char32_t {return ::zp::det::cxx11::val<char32_t>::max();}
+ };
+
+ #if __cpp_char8_t >= 201811
+ template<> struct val<char8_t> {
+ constexpr static auto min() noexcept -> char8_t {return zp_minvalc8;}
+ constexpr static auto max() noexcept -> char8_t {return zp_maxvalc8;}
+
+
+ constexpr static auto nan() noexcept -> char8_t {return u8'\x00';}
+ constexpr static auto inf() noexcept -> char8_t {return ::zp::det::cxx11::val<char8_t>::max();}
+ };
+ #endif // char8_t
+
+ template<> struct val<double> {
+ constexpr static auto min() noexcept -> double {return zp_minvald;}
+ constexpr static auto max() noexcept -> double {return zp_maxvald;}
+
+ constexpr static auto nan() noexcept -> double {return zp_nand;}
+ constexpr static auto inf() noexcept -> double {return zp_infd;}
+ };
+
+ template<> struct val<double long> {
+ constexpr static auto min() noexcept -> double long {return zp_minvaldl;}
+ constexpr static auto max() noexcept -> double long {return zp_maxvaldl;}
+
+ constexpr static auto nan() noexcept -> double long {return zp_nandl;}
+ constexpr static auto inf() noexcept -> double long {return zp_infdl;}
+ };
+
+ template<> struct val<float> {
+ constexpr static auto min() noexcept -> float {return zp_minvalf;}
+ constexpr static auto max() noexcept -> float {return zp_maxvalf;}
+
+ constexpr static auto nan() noexcept -> float {return zp_nanf;}
+ constexpr static auto inf() noexcept -> float {return zp_inff;}
+ };
+
+ #if __STDCPP_BFLOAT16_T__
+ template<> struct val<decltype (0.0bf16)> {
+ constexpr static auto min() noexcept -> decltype (0.0bf16) {return 0.0bf16;}
+ constexpr static auto max() noexcept -> decltype (0.0bf16) {return 0.0bf16;}
+
+ constexpr static auto inf() noexcept -> decltype (0.0bf16) {return 0.0bf16;}
+ constexpr static auto nan() noexcept -> decltype (0.0bf16) {return 0.0bf16;}
+ };
+ #endif // bfloat16_t
+
+ #if __STDCPP_FLOAT128_T__
+ template<> struct val<decltype (0.0f128)> {
+ constexpr static auto min() noexcept -> decltype (0.0f128) {return -1.189731495357231765085759326628007016196469052641694045529698884212163579755312392324974012848462073525902033564749126859755265433573804462672698751945261490853461958725021262845865799405404493574681566096686172574953791792292256220777095858112702436475442537092608935138247345677279593806773692330094615746119725784172889892521939920757654204864565673356452247278152288867700638935595456496699511441752909606878513250948311396886100526833092128683974752192266386791880873694343077348155564101669971138512786874753496996549221727686770196551512812712488289469952298031867469924683981576664562667786719061499639630341657098305425237220876664630087808767256182803220212219924852375903049520911395910918921205273496768588119030111593018789368039232011671404175845108854706965215605777113516257404818817695075025715299705916714352103671782759119316034498392169720631800164034124698918142227577300459309880454715179606299895507583075851195185857971173167676966057998899352631885417716295302014668802384075846036226606480142977595407135050379808649130157164024060311786908796372510335873512774795275748595417572920936651398752709055215663939505589207804914540432978557623565645991208599669097180808881920063722771431218489011922209679053545963628417326002439732802939524313786668514027381434321036636571171670423586472759561231970793967839279147282720195377060602122638457883204809341717526809639253539447730280863675704796054050525162959099932535265586464682793821550087166946662209865086040990507131145474267411042839542322762994938759613112743837192839682676257555388372814490845395747128162065871588219108887240116651361962050800029176299938826082417547516732269930473133261258921845516815235455354310458114528303607394526100730578774092094736822286015459361126642549541799645333882549670764145955017051330800061253865140180153211929361456500343514792890205532021760061882232615736553377294980974059590520187961459799386741513028505934410453603480192383349321115171811051004108592830991811382552909064873029533418691087118107895004426881765865961841419267486232005929789956207494587649901662172318722999484512325826087031561936383689740686505279775296789331613683822798597040651600524129025149894873153196942095056670847466927644812596506700129443579512479230621373978088731257089799622902183824105412930483065603459863120371744282301377070153823878609951218937542956964157950988060608985782910656238116142203574104757451828170804875257446204128348513829082731722364189380493588338947664370623279820755831646205417488393062838201789547219543194450902113699925965376908192792152122212824578879336506875288617303469517112245451315447164280392523574962804175375927948971096983905242318797695347043690474223813266505639761164438844266531364626851219633994434154098562127395936184421821444273431534507860161614287022720984061569660333372788241037131538077377480152670583257920535569973318188112685673318997967497786786001251403873023920127717626858627038170562807276699687356274072773403132694104831615879354395811585825112837841563222761623334459188131537882355732483030085976890382969734476214593428191212717141333047577867552218517431064848760373196290310124466145087078377140528533048684204278799596652514009368964527494988719996088230065668196236298805733689960371306226158464997243490564472254071897564144128539839986096045563264771285585066304177995720101744844387158329767375560416207800878830072072413908657855667239546369357775781344288195989176313356856417845434232814886744226746707066979755577121788798468777700116472954103621810567107869855646414713502627836321256957407217461738363552424248762436478085351810995749293238174081331905048144612700905541425702220302537611494824228765324577933778519818778697340282580912780674979058938062556856001076057705982166686824756037569615760497619819482052758118532729333127733603742149847001463931981340719681330844408263017545241644293372483217234561694263937855759294448662979095419227451801588425977869694026601427919655168415895923043115191751872713346095752634608254475988154162254952597853199039645883742199236387610395830948074365988397707849632252080920941206268114832425403540515474312327876180802357701527842702008781378306569508588571830140611098042683009530862797403015355464377406249853964481000402231771665700893607521804084523668568649103258862666293372472441435563520595461701042390500795615834505944837326652542467444364861499184275097485253621979537504128523848241127715641240965261646703516395599407360083455079665191393229410544185167999099787655424462558900874388405649169453726739312260234815543297842308646072190147948072928456725835039546121182133640777769925841807579051735838823112759622714067509669913645288281894558925612972425252452248453502562347348900936766966136332741088135837550717443838484760651019872222926016920811114616937143207743488504602012776364256746872315205952601072228970686460932435222754496341763535189105548847634608972381760403137363968e+4932f128;}
+ constexpr static auto max() noexcept -> decltype (0.0f128) {return +1.189731495357231765085759326628007016196469052641694045529698884212163579755312392324974012848462073525902033564749126859755265433573804462672698751945261490853461958725021262845865799405404493574681566096686172574953791792292256220777095858112702436475442537092608935138247345677279593806773692330094615746119725784172889892521939920757654204864565673356452247278152288867700638935595456496699511441752909606878513250948311396886100526833092128683974752192266386791880873694343077348155564101669971138512786874753496996549221727686770196551512812712488289469952298031867469924683981576664562667786719061499639630341657098305425237220876664630087808767256182803220212219924852375903049520911395910918921205273496768588119030111593018789368039232011671404175845108854706965215605777113516257404818817695075025715299705916714352103671782759119316034498392169720631800164034124698918142227577300459309880454715179606299895507583075851195185857971173167676966057998899352631885417716295302014668802384075846036226606480142977595407135050379808649130157164024060311786908796372510335873512774795275748595417572920936651398752709055215663939505589207804914540432978557623565645991208599669097180808881920063722771431218489011922209679053545963628417326002439732802939524313786668514027381434321036636571171670423586472759561231970793967839279147282720195377060602122638457883204809341717526809639253539447730280863675704796054050525162959099932535265586464682793821550087166946662209865086040990507131145474267411042839542322762994938759613112743837192839682676257555388372814490845395747128162065871588219108887240116651361962050800029176299938826082417547516732269930473133261258921845516815235455354310458114528303607394526100730578774092094736822286015459361126642549541799645333882549670764145955017051330800061253865140180153211929361456500343514792890205532021760061882232615736553377294980974059590520187961459799386741513028505934410453603480192383349321115171811051004108592830991811382552909064873029533418691087118107895004426881765865961841419267486232005929789956207494587649901662172318722999484512325826087031561936383689740686505279775296789331613683822798597040651600524129025149894873153196942095056670847466927644812596506700129443579512479230621373978088731257089799622902183824105412930483065603459863120371744282301377070153823878609951218937542956964157950988060608985782910656238116142203574104757451828170804875257446204128348513829082731722364189380493588338947664370623279820755831646205417488393062838201789547219543194450902113699925965376908192792152122212824578879336506875288617303469517112245451315447164280392523574962804175375927948971096983905242318797695347043690474223813266505639761164438844266531364626851219633994434154098562127395936184421821444273431534507860161614287022720984061569660333372788241037131538077377480152670583257920535569973318188112685673318997967497786786001251403873023920127717626858627038170562807276699687356274072773403132694104831615879354395811585825112837841563222761623334459188131537882355732483030085976890382969734476214593428191212717141333047577867552218517431064848760373196290310124466145087078377140528533048684204278799596652514009368964527494988719996088230065668196236298805733689960371306226158464997243490564472254071897564144128539839986096045563264771285585066304177995720101744844387158329767375560416207800878830072072413908657855667239546369357775781344288195989176313356856417845434232814886744226746707066979755577121788798468777700116472954103621810567107869855646414713502627836321256957407217461738363552424248762436478085351810995749293238174081331905048144612700905541425702220302537611494824228765324577933778519818778697340282580912780674979058938062556856001076057705982166686824756037569615760497619819482052758118532729333127733603742149847001463931981340719681330844408263017545241644293372483217234561694263937855759294448662979095419227451801588425977869694026601427919655168415895923043115191751872713346095752634608254475988154162254952597853199039645883742199236387610395830948074365988397707849632252080920941206268114832425403540515474312327876180802357701527842702008781378306569508588571830140611098042683009530862797403015355464377406249853964481000402231771665700893607521804084523668568649103258862666293372472441435563520595461701042390500795615834505944837326652542467444364861499184275097485253621979537504128523848241127715641240965261646703516395599407360083455079665191393229410544185167999099787655424462558900874388405649169453726739312260234815543297842308646072190147948072928456725835039546121182133640777769925841807579051735838823112759622714067509669913645288281894558925612972425252452248453502562347348900936766966136332741088135837550717443838484760651019872222926016920811114616937143207743488504602012776364256746872315205952601072228970686460932435222754496341763535189105548847634608972381760403137363968e+4932f128;}
+
+ constexpr static auto inf() noexcept -> decltype (0.0f128) {return 0.0f128;}
+ constexpr static auto nan() noexcept -> decltype (0.0f128) {return 0.0f128;}
+ };
+ #endif // float128_t
+
+ #if __STDCPP_FLOAT32_T__
+ template<> struct val<decltype (0.0f32)> {
+ constexpr static auto min() noexcept -> decltype (0.0f32) {return -3.40282346638528859811704183484516925440e+38f32;}
+ constexpr static auto max() noexcept -> decltype (0.0f32) {return +3.40282346638528859811704183484516925440e+38f32;}
+
+ constexpr static auto inf() noexcept -> decltype (0.0f32) {return 0.0f32;}
+ constexpr static auto nan() noexcept -> decltype (0.0f32) {return 0.0f32;}
+ };
+ #endif // float32_t
+
+ #if __STDCPP_FLOAT64_T__
+ template<> struct val<decltype (0.0f64)> {
+ constexpr static auto min() noexcept -> decltype (0.0f64) {return -1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e+308f64;}
+ constexpr static auto max() noexcept -> decltype (0.0f64) {return +1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e+308f64;}
+
+ constexpr static auto inf() noexcept -> decltype (0.0f64) {return 0.0f64;}
+ constexpr static auto nan() noexcept -> decltype (0.0f64) {return 0.0f64;}
+ };
+ #endif // float64_t
+
+ template<> struct val<int> {
+ constexpr static auto min() noexcept -> int {return zp_minvali;}
+ constexpr static auto max() noexcept -> int {return zp_maxvali;}
+
+ constexpr static auto nan() noexcept -> int {return 0x0;}
+ constexpr static auto inf() noexcept -> int {return ::zp::det::cxx11::val<int>::max();}
+ };
+
+ template<> struct val<int long> {
+ constexpr static auto min() noexcept -> int long {return zp_minvalil;}
+ constexpr static auto max() noexcept -> int long {return zp_maxvalil;}
+
+
+ constexpr static auto nan() noexcept -> int long {return 0x0l;}
+ constexpr static auto inf() noexcept -> int long {return ::zp::det::cxx11::val<int long>::max();}
+ };
+
+ template<> struct val<int long long> {
+ constexpr static auto min() noexcept -> int long long {return zp_minvalill;}
+ constexpr static auto max() noexcept -> int long long {return zp_maxvalill;}
+
+ constexpr static auto nan() noexcept -> int long long {return 0x0ll;}
+ constexpr static auto inf() noexcept -> int long long {return ::zp::det::cxx11::val<int long long>::max();}
+ };
+
+ template<> struct val<int long long unsigned> {
+ constexpr static auto min() noexcept -> int long long unsigned {return zp_minvalillu;}
+ constexpr static auto max() noexcept -> int long long unsigned {return zp_maxvalillu;}
+
+ constexpr static auto nan() noexcept -> int long long unsigned {return 0x0llu;}
+ constexpr static auto inf() noexcept -> int long long unsigned {return ::zp::det::cxx11::val<int long long unsigned>::max();}
+ };
+
+ template<> struct val<int long unsigned> {
+ constexpr static auto min() noexcept -> int long unsigned {return zp_minvalilu;}
+ constexpr static auto max() noexcept -> int long unsigned {return zp_maxvalilu;}
+
+
+ constexpr static auto nan() noexcept -> int long unsigned {return 0x0lu;}
+ constexpr static auto inf() noexcept -> int long unsigned {return ::zp::det::cxx11::val<int long unsigned>::max();}
+ };
+
+ template<> struct val<int short> {
+ constexpr static auto min() noexcept -> int short {return zp_minvalis;}
+ constexpr static auto max() noexcept -> int short {return zp_maxvalis;}
+
+ constexpr static auto nan() noexcept -> int short {return 0x0;}
+ constexpr static auto inf() noexcept -> int short {return ::zp::det::cxx11::val<int short>::max();}
+ };
+
+ template<> struct val<int short unsigned> {
+ constexpr static auto min() noexcept -> int short unsigned {return zp_minvalisu;}
+ constexpr static auto max() noexcept -> int short unsigned {return zp_maxvalisu;}
+
+ constexpr static auto nan() noexcept -> int short unsigned {return 0x0u;}
+ constexpr static auto inf() noexcept -> int short unsigned {return ::zp::det::cxx11::val<int short unsigned>::max();}
+ };
+
+ template<> struct val<int unsigned> {
+ constexpr static auto min() noexcept -> int unsigned {return zp_minvaliu;}
+ constexpr static auto max() noexcept -> int unsigned {return zp_maxvaliu;}
+
+ constexpr static auto nan() noexcept -> int unsigned {return 0x0u;}
+ constexpr static auto inf() noexcept -> int unsigned {return ::zp::det::cxx11::val<int unsigned>::max();}
+ };
+
+ template<> struct val<wchar_t> {
+ constexpr static auto min() noexcept -> wchar_t {return zp_minvalw;}
+ constexpr static auto max() noexcept -> wchar_t {return zp_maxvalw;}
+
+ constexpr static auto nan() noexcept -> wchar_t {return L'\x00';}
+ constexpr static auto inf() noexcept -> wchar_t {return ::zp::det::cxx11::val<wchar_t>::max();}
+ };
+ }
+ }
+ using det::cxx11::val;
+#else
+ namespace det {
+ namespace cxx11 {
+ template<typename typ> struct val {
+ zp_nothw zp_unseq static typ min() {return typ();}
+ zp_nothw zp_unseq static typ max() {return typ();}
+
+ zp_nothw zp_unseq static typ nan() {return typ();}
+ zp_nothw zp_unseq static typ inf() {return typ();}
+ };
+
+ template<typename typ> struct val<typ const> {
+ zp_nothw zp_unseq static typ min() {return ::zp::det::cxx11::val<typ>::min();}
+ zp_nothw zp_unseq static typ max() {return ::zp::det::cxx11::val<typ>::max();}
+
+ zp_nothw zp_unseq static typ nan() {return ::zp::det::cxx11::val<typ>::nan();}
+ zp_nothw zp_unseq static typ inf() {return ::zp::det::cxx11::val<typ>::inf();}
+ };
+
+ template<typename typ> struct val<typ volatile> {
+ zp_nothw zp_unseq static typ min() {return ::zp::det::cxx11::val<typ>::min();}
+ zp_nothw zp_unseq static typ max() {return ::zp::det::cxx11::val<typ>::max();}
+
+ zp_nothw zp_unseq static typ nan() {return ::zp::det::cxx11::val<typ>::nan();}
+ zp_nothw zp_unseq static typ inf() {return ::zp::det::cxx11::val<typ>::inf();}
+ };
+
+ template<typename typ> struct val<typ const volatile> {
+ zp_nothw zp_unseq static typ min() {return ::zp::det::cxx11::val<typ>::min();}
+ zp_nothw zp_unseq static typ max() {return ::zp::det::cxx11::val<typ>::max();}
+
+ zp_nothw zp_unseq static typ nan() {return ::zp::det::cxx11::val<typ>::nan();}
+ zp_nothw zp_unseq static typ inf() {return ::zp::det::cxx11::val<typ>::inf();}
+ };
+
+ template<> struct val<bool> {
+ zp_nothw zp_unseq static bool min() {return false;}
+ zp_nothw zp_unseq static bool max() {return true;}
+ };
+
+ template<> struct val<char> {
+ zp_nothw zp_unseq static char min() {return zp_minvalc;}
+ zp_nothw zp_unseq static char max() {return zp_maxvalc;}
+ };
+
+ template<> struct val<char signed> {
+ zp_nothw zp_unseq static char signed min() {return zp_minvalcs;}
+ zp_nothw zp_unseq static char signed max() {return zp_maxvalcs;}
+ };
+
+ template<> struct val<char unsigned> {
+ zp_nothw zp_unseq static char unsigned min() {return zp_minvalcu;}
+ zp_nothw zp_unseq static char unsigned max() {return zp_maxvalcu;}
+ };
+
+ template<> struct val<double> {
+ zp_nothw zp_unseq static double min() {return zp_minvald;}
+ zp_nothw zp_unseq static double max() {return zp_maxvald;}
+ };
+
+ template<> struct val<double long> {
+ zp_nothw zp_unseq static double long min() {return zp_minvaldl;}
+ zp_nothw zp_unseq static double long max() {return zp_maxvaldl;}
+ };
+
+ template<> struct val<float> {
+ zp_nothw zp_unseq static float min() {return zp_minvalf;}
+ zp_nothw zp_unseq static float max() {return zp_maxvalf;}
+ };
+
+ template<> struct val<int> {
+ zp_nothw zp_unseq static int min() {return zp_minvali;}
+ zp_nothw zp_unseq static int max() {return zp_maxvali;}
+ };
+
+ template<> struct val<int long> {
+ zp_nothw zp_unseq static int long min() {return zp_minvalil;}
+ zp_nothw zp_unseq static int long max() {return zp_maxvalil;}
+ };
+
+ template<> struct val<int long unsigned> {
+ zp_nothw zp_unseq static int long unsigned min() {return zp_minvalilu;}
+ zp_nothw zp_unseq static int long unsigned max() {return zp_maxvalilu;}
+ };
+
+ template<> struct val<int short> {
+ zp_nothw zp_unseq static int short min() {return zp_minvalis;}
+ zp_nothw zp_unseq static int short max() {return zp_maxvalis;}
+ };
+
+ template<> struct val<int short unsigned> {
+ zp_nothw zp_unseq static int short unsigned min() {return zp_minvalisu;}
+ zp_nothw zp_unseq static int short unsigned max() {return zp_maxvalisu;}
+ };
+
+ template<> struct val<int unsigned> {
+ zp_nothw zp_unseq static int unsigned min() {return zp_minvaliu;}
+ zp_nothw zp_unseq static int unsigned max() {return zp_maxvaliu;}
+ };
+
+ template<> struct val<wchar_t> {
+ zp_nothw zp_unseq static wchar_t min() {return zp_minvalw;}
+ zp_nothw zp_unseq static wchar_t max() {return zp_maxvalw;}
+ };
+ }
+ }
+#endif
+
+#if zp_std_cxx11
template<typename typ> struct isptr {constexpr static bool val = false;};
template<typename typ> struct isptr<typ *> {constexpr static bool val = true;};
@@ -468,32 +732,10 @@ namespace zp {
#endif // c++11
#if zp_std_cxx11
- template<typename typ> struct nan {constexpr static typ val = typ {0x0};};
-
- template<typename typ> struct nan<typ const> {constexpr static typ val = nan<typ>::val;};
- template<typename typ> struct nan<typ volatile> {constexpr static typ val = nan<typ>::val;};
- template<typename typ> struct nan<typ const volatile> {constexpr static typ val = nan<typ>::val;};
-
- template<> struct nan<double> {constexpr static double const val = zp_nanf;};
- template<> struct nan<double long> {constexpr static double long const val = zp_nandl;};
- template<> struct nan<float> {constexpr static float const val = zp_nand;};
-
- template<typename typ> struct inf {constexpr static typ val = ::zp::typ<typ>::max;};
-
- template<typename typ> struct inf<typ const> {constexpr static typ val = inf<typ>::val;};
- template<typename typ> struct inf<typ volatile> {constexpr static typ val = inf<typ>::val;};
- template<typename typ> struct inf<typ const volatile> {constexpr static typ val = inf<typ>::val;};
-
- template<> struct inf<double> {constexpr static double const val = zp_inff;};
- template<> struct inf<double long> {constexpr static double long const val = zp_infdl;};
- template<> struct inf<float> {constexpr static float const val = zp_infd;};
-#endif
-
-#if zp_std_cxx11
namespace det {
namespace cxx11 {
template<typename typ> zp_unseq constexpr auto nulptr() noexcept -> typ * {
- //static_assert(,"");
+ //static_assert(!::zp::typ<typ>::isref,"");
return zp_nulptr(typ);
}
}
@@ -502,7 +744,7 @@ namespace zp {
#else
namespace det {
namespace cxx98 {
- template<typename typ> zp_unseq typ * nulptr() {return zp_nulptr(typ);}
+ template<typename typ> zp_unseq zp_nothw typ * nulptr() {return zp_nulptr(typ);}
}
}
using det::cxx98::nulptr;
@@ -527,7 +769,7 @@ namespace zp {
auto val() const noexcept -> typ const&;
- template<typename funtyp,typename msgtyp> auto exp(funtyp const & fun,msgtyp const & msg) const noexcept -> typ const&;
+ template<typename funtyp,typename... argtyp> auto exp(funtyp const & fun,argtyp const&... arg) const noexcept -> typ const&;
auto operator =(::zp::det::nulopttyp) noexcept -> ::zp::opt<typ> &;
auto operator =(typ const& val) -> ::zp::opt<typ> &;
@@ -559,7 +801,7 @@ namespace zp {
auto getoky() const noexcept -> okytyp const&;
auto geterr() const noexcept -> errtyp const&;
- template<typename funtyp,typename msgtyp> auto exp(funtyp const& fun,msgtyp const& msg) const noexcept -> okytyp const&; // UB if fun returns or throws an uncaught exception.
+ template<typename funtyp,typename... funarg> auto exp(funtyp const& fun,funarg const&... arg) const noexcept -> okytyp const&; // UB if fun returns or throws an uncaught exception.
auto operator =(::zp::res<okytyp,errtyp> const& oth) -> ::zp::res<okytyp,errtyp> &;
auto operator =(::zp::res<okytyp,errtyp> && oth) -> ::zp::res<okytyp,errtyp> &;
diff --git a/zp/include/zp/zp.h b/zp/include/zp/zp.h
index a31bc04..463332a 100644
--- a/zp/include/zp/zp.h
+++ b/zp/include/zp/zp.h
@@ -4,9 +4,11 @@
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/
-/* All identifiers in the "priv" namespaces are, */
-/* well, private, and may not be used by any */
-/* program (causes UB or something). */
+/*
+ All identifiers in the "prv" and "det"
+ namespaces are, well, private, and may not be
+ used by any program (causes UB or something).
+*/
/*
Greater Header Dependencies:
diff --git a/zp/source/amd64/zp/trp.s b/zp/source/amd64/zp/trp.s
deleted file mode 100644
index 91efa4e..0000000
--- a/zp/source/amd64/zp/trp.s
+++ /dev/null
@@ -1,8 +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>.
-
-global zp_trp
-
-zp_trp:
- ud2
diff --git a/zp/source/any/mem/memcpy.c b/zp/source/any/mem/memcpy.c
index 8ea32d3..380ed04 100644
--- a/zp/source/any/mem/memcpy.c
+++ b/zp/source/any/mem/memcpy.c
@@ -9,7 +9,7 @@
zp_nothw zp_cpyres zp_memcpy(void * const dstptr,void const* const srcptr,zp_siz const num) {
zp_cpyres res;
- char unsigned * dst = dstptr;
+ char unsigned * dst = dstptr;
char unsigned const* src = srcptr;
char unsigned * const stp = dst+num;
diff --git a/zp/source/any/zp/trp.c b/zp/source/any/zp/trp.c
index 0aea358..6296b9a 100644
--- a/zp/source/any/zp/trp.c
+++ b/zp/source/any/zp/trp.c
@@ -6,9 +6,32 @@
#include <zp/zp.h>
+#if zp_sys_lnx
+#include <linux/unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+#endif
+
void zp_trp(void) {
-#if zp_prv_hasbltin(__builtin_trap)
- __builtin_trap();
+#if zp_sys_lnx
+
+ zp_syscal(__NR_kill,(pid_t)zp_syscal(__NR_getpid),SIGTRAP);
+
+#elif zp_imp_gcc
+#if zp_arc_amd64
+
+ __asm__ (
+ "ud2\n"
+ );
+
#endif
+#elif zp_imp_msc
+#if zp_arc_amd64
+
+ __asm ud2;
+
+#endif
+#endif
+
for (;;) {}
}
diff --git a/zp/source/arm64/zp/syscal.s b/zp/source/arm64/zp/syscal.s
index b5d928e..890231b 100644
--- a/zp/source/arm64/zp/syscal.s
+++ b/zp/source/arm64/zp/syscal.s
@@ -6,7 +6,7 @@
zp_syscal:
/* System calls on ARM64 use the following registers: */
- /* x0 : System call identifier */
+ /* x8 : System call identifier */
/* x1 : First parameter */
/* x2 : Second parameter */
/* x3 : Third parameter */