diff options
-rw-r--r-- | CHANGELOG.txt | 7 | ||||
-rw-r--r-- | test.cc | 164 | ||||
-rw-r--r-- | zp/include/zp/det/mem.ii | 35 | ||||
-rw-r--r-- | zp/include/zp/mem | 37 | ||||
-rw-r--r-- | zp/include/zp/prv/flt.h | 4 | ||||
-rw-r--r-- | zp/include/zp/zp | 550 |
6 files changed, 523 insertions, 274 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 18cfe6a..8c658c4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,13 @@ * Make nulptr into a function; +* Remove isusgn; +* Replace C++ maxval, minval, is*typ, and issgn classes with common metaprogramming class: typ; +* Add metaprogramming class for detecting reference types: isref; +* Fix infdl; +* Rename remqual to remcv; +* Fix nan and inf for qualified types; + # 1.1.1 * Fix res dtor calls; @@ -32,6 +32,12 @@ static_assert(::zp::isptr<int const * const volatile>::val == true); static_assert(::zp::isptr<int volatile * const volatile>::val == true); static_assert(::zp::isptr<int const volatile * const volatile>::val == true); +static_assert(::zp::isref<int>::val == false); +static_assert(::zp::isref<int &>::val == true); +static_assert(::zp::isref<int const&>::val == true); +static_assert(::zp::isref<int volatile&>::val == true); +static_assert(::zp::isref<int const volatile&>::val == true); + static_assert(::zp::typequ<int,int>::val == true); static_assert(::zp::typequ<int,int long>::val == false); @@ -57,10 +63,10 @@ static_assert(::zp::typequ<::zp::remptr<int * const>::typ, int>::val == static_assert(::zp::typequ<::zp::remptr<int * volatile>::typ, int>::val == true); static_assert(::zp::typequ<::zp::remptr<int * const volatile>::typ,int>::val == true); -static_assert(::zp::typequ<::zp::remqual<int>::typ, int>::val == true); -static_assert(::zp::typequ<::zp::remqual<int const>::typ, int>::val == true); -static_assert(::zp::typequ<::zp::remqual<int volatile>::typ, int>::val == true); -static_assert(::zp::typequ<::zp::remqual<int const volatile>::typ,int>::val == true); +static_assert(::zp::typequ<::zp::remcv<int>::typ, int>::val == true); +static_assert(::zp::typequ<::zp::remcv<int const>::typ, int>::val == true); +static_assert(::zp::typequ<::zp::remcv<int volatile>::typ, int>::val == true); +static_assert(::zp::typequ<::zp::remcv<int const volatile>::typ,int>::val == true); static_assert(::zp::typequ<::zp::sgn<int>::typ, int>::val == true); static_assert(::zp::typequ<::zp::sgn<int const>::typ, int const>::val == true); @@ -82,93 +88,69 @@ static_assert(::zp::typequ<::zp::usgn<int const volatile>::typ, int unsi static_assert(::zp::typequ<::zp::nulptrtyp,::std::nullptr_t>::val == true); -static_assert(::zp::isusgn<char>::val == ::std::is_unsigned<char>::value); -static_assert(::zp::isusgn<char16_t>::val == ::std::is_unsigned<char16_t>::value); -static_assert(::zp::isusgn<char32_t>::val == ::std::is_unsigned<char32_t>::value); -static_assert(::zp::isusgn<::zp::c8>::val == ::std::is_unsigned<::zp::c8>::value); -static_assert(::zp::isusgn<double>::val == ::std::is_unsigned<double>::value); -static_assert(::zp::isusgn<float>::val == ::std::is_unsigned<float>::value); -static_assert(::zp::isusgn<int>::val == ::std::is_unsigned<int>::value); -static_assert(::zp::isusgn<int long>::val == ::std::is_unsigned<int long>::value); -static_assert(::zp::isusgn<double long>::val == ::std::is_unsigned<double long>::value); -static_assert(::zp::isusgn<int long long>::val == ::std::is_unsigned<int long long>::value); -static_assert(::zp::isusgn<int short>::val == ::std::is_unsigned<int short>::value); -static_assert(::zp::isusgn<char signed>::val == ::std::is_unsigned<char signed>::value); -static_assert(::zp::isusgn<char unsigned>::val == ::std::is_unsigned<char unsigned>::value); -static_assert(::zp::isusgn<int unsigned>::val == ::std::is_unsigned<int unsigned>::value); -static_assert(::zp::isusgn<int long unsigned>::val == ::std::is_unsigned<int long unsigned>::value); -static_assert(::zp::isusgn<int long long unsigned>::val == ::std::is_unsigned<int long long unsigned>::value); -static_assert(::zp::isusgn<int short unsigned>::val == ::std::is_unsigned<int short unsigned>::value); -static_assert(::zp::isusgn<wchar_t>::val == ::std::is_unsigned<wchar_t>::value); - -static_assert(::zp::issgn<char>::val == ::std::is_signed<char>::value); -static_assert(::zp::issgn<double>::val == ::std::is_signed<double>::value); -static_assert(::zp::issgn<float>::val == ::std::is_signed<float>::value); -static_assert(::zp::issgn<int>::val == ::std::is_signed<int>::value); -static_assert(::zp::issgn<int long>::val == ::std::is_signed<int long>::value); -static_assert(::zp::issgn<double long>::val == ::std::is_signed<double long>::value); -static_assert(::zp::issgn<int long long>::val == ::std::is_signed<int long long>::value); -static_assert(::zp::issgn<int short>::val == ::std::is_signed<int short>::value); -static_assert(::zp::issgn<char signed>::val == ::std::is_signed<char signed>::value); -static_assert(::zp::issgn<char unsigned>::val == ::std::is_signed<char unsigned>::value); -static_assert(::zp::issgn<int unsigned>::val == ::std::is_signed<int unsigned>::value); -static_assert(::zp::issgn<int long unsigned>::val == ::std::is_signed<int long unsigned>::value); -static_assert(::zp::issgn<int long long unsigned>::val == ::std::is_signed<int long long unsigned>::value); -static_assert(::zp::issgn<int short unsigned>::val == ::std::is_signed<int short unsigned>::value); -static_assert(::zp::issgn<wchar_t>::val == ::std::is_signed<wchar_t>::value); - static_assert(::zp::bytelen == CHAR_BIT); -static_assert(::zp::minval<bool>::val == ::std::numeric_limits<bool>::lowest()); -static_assert(::zp::minval<char>::val == ::std::numeric_limits<char>::lowest()); -static_assert(::zp::minval<char16_t>::val == ::std::numeric_limits<char16_t>::lowest()); -static_assert(::zp::minval<char32_t>::val == ::std::numeric_limits<char32_t>::lowest()); -static_assert(::zp::minval<::zp::c8>::val == ::std::numeric_limits<::zp::c8>::lowest()); -static_assert(::zp::minval<double>::val == ::std::numeric_limits<double>::lowest()); -static_assert(::zp::minval<float>::val == ::std::numeric_limits<float>::lowest()); -static_assert(::zp::minval<int>::val == ::std::numeric_limits<int>::lowest()); -static_assert(::zp::minval<int long>::val == ::std::numeric_limits<int long>::lowest()); -static_assert(::zp::minval<double long>::val == ::std::numeric_limits<double long>::lowest()); -static_assert(::zp::minval<int long long>::val == ::std::numeric_limits<int long long>::lowest()); -static_assert(::zp::minval<int short>::val == ::std::numeric_limits<int short>::lowest()); -static_assert(::zp::minval<char signed>::val == ::std::numeric_limits<char signed>::lowest()); -static_assert(::zp::minval<char unsigned>::val == ::std::numeric_limits<char unsigned>::lowest()); -static_assert(::zp::minval<int short unsigned>::val == ::std::numeric_limits<int short unsigned>::lowest()); -static_assert(::zp::minval<int unsigned>::val == ::std::numeric_limits<int unsigned>::lowest()); -static_assert(::zp::minval<int long unsigned>::val == ::std::numeric_limits<int long unsigned>::lowest()); -static_assert(::zp::minval<int long long unsigned>::val == ::std::numeric_limits<int long long unsigned>::lowest()); -static_assert(::zp::minval<wchar_t>::val == ::std::numeric_limits<wchar_t>::lowest()); - -static_assert(::zp::maxval<bool>::val == ::std::numeric_limits<bool>::max()); -static_assert(::zp::maxval<char>::val == ::std::numeric_limits<char>::max()); -static_assert(::zp::maxval<char16_t>::val == ::std::numeric_limits<char16_t>::max()); -static_assert(::zp::maxval<char32_t>::val == ::std::numeric_limits<char32_t>::max()); -static_assert(::zp::maxval<::zp::c8>::val == ::std::numeric_limits<::zp::c8>::max()); -static_assert(::zp::maxval<double>::val == ::std::numeric_limits<double>::max()); -static_assert(::zp::maxval<float>::val == ::std::numeric_limits<float>::max()); -static_assert(::zp::maxval<int>::val == ::std::numeric_limits<int>::max()); -static_assert(::zp::maxval<int long>::val == ::std::numeric_limits<int long>::max()); -static_assert(::zp::maxval<double long>::val == ::std::numeric_limits<double long>::max()); -static_assert(::zp::maxval<int long long>::val == ::std::numeric_limits<int long long>::max()); -static_assert(::zp::maxval<int short>::val == ::std::numeric_limits<int short>::max()); -static_assert(::zp::maxval<char signed>::val == ::std::numeric_limits<char signed>::max()); -static_assert(::zp::maxval<char unsigned>::val == ::std::numeric_limits<char unsigned>::max()); -static_assert(::zp::maxval<int short unsigned>::val == ::std::numeric_limits<int short unsigned>::max()); -static_assert(::zp::maxval<int unsigned>::val == ::std::numeric_limits<int unsigned>::max()); -static_assert(::zp::maxval<int long unsigned>::val == ::std::numeric_limits<int long unsigned>::max()); -static_assert(::zp::maxval<int long long unsigned>::val == ::std::numeric_limits<int long long unsigned>::max()); -static_assert(::zp::maxval<wchar_t>::val == ::std::numeric_limits<wchar_t>::max()); +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 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>);} + + static_assert(typ::isflt == ::std::is_floating_point_v<typtyp>); + + static_assert(nulptr<typtyp>() == nullptr); + + static_assert(typ::hassgn == numlim::is_signed); + + static_assert(typ::min == numlim::lowest()); + static_assert(typ::max == numlim::max()); + + if constexpr (typ::isflt) { + static_assert(inf<typtyp>::val == numlim::infinity()); + } + + return true; +} + +template<typename typ> constexpr static auto chktypcv() noexcept -> bool { + return ::chktyp<typ>() && ::chktyp<typ const>() && ::chktyp<typ volatile>() && ::chktyp<typ const volatile>(); +} + +static_assert(::chktypcv<bool>() == true); +static_assert(::chktypcv<char>() == true); +static_assert(::chktypcv<char signed>() == true); +static_assert(::chktypcv<char unsigned>() == true); +static_assert(::chktypcv<char16_t>() == true); +static_assert(::chktypcv<char32_t>() == true); +static_assert(::chktypcv<::zp::c8>() == true); +static_assert(::chktypcv<double>() == true); +static_assert(::chktypcv<double long>() == true); +static_assert(::chktypcv<float>() == true); +static_assert(::chktypcv<int>() == true); +static_assert(::chktypcv<int long>() == true); +static_assert(::chktypcv<int long long>() == true); +static_assert(::chktypcv<int long long unsigned>() == true); +static_assert(::chktypcv<int long unsigned>() == true); +static_assert(::chktypcv<int short>() == true); +static_assert(::chktypcv<int short unsigned>() == true); +static_assert(::chktypcv<int unsigned>() == true); +static_assert(::chktypcv<wchar_t>() == true); template<typename ltyp,typename rtyp> static auto cmp(int unsigned & numerr,int long const ln,::zp::i8 const mth,ltyp const& lvalref,rtyp const& rvalref) noexcept { char const* const ltypnm = typeid (ltyp).name(); char const* const rtypnm = typeid (rtyp).name(); auto const getval = [](auto const& valref) { - using typ = typename ::zp::remqual<typename ::zp::remref<decltype (valref)>::typ>::typ; + using typ = typename ::zp::remcv<typename ::zp::remref<decltype (valref)>::typ>::typ; - if constexpr (::zp::ischrtyp<typ>::val) {return static_cast<::zp::i02>(valref);} - else if constexpr (::zp::isptr<typ>::val) {return reinterpret_cast<void *>(valref);} - else {return valref;} + if constexpr (::zp::typ<typ>::ischr) {return static_cast<::zp::i02>(valref);} + else if constexpr (::zp::isptr<typ>::val) {return reinterpret_cast<void *>(valref);} + else {return valref;} }; auto const lval = getval(lvalref); @@ -334,8 +316,8 @@ int main() { f02 = ::zp::inf<::zp::f02>::val; f04 = ::zp::inf<::zp::f04>::val; - chkeq(f02 > ::zp::maxval<::zp::f02>::val,true); - chkeq(f04 > ::zp::maxval<::zp::f04>::val,true); + chkgt(f02,::zp::typ<::zp::f02>::max); + chkgt(f04,::zp::typ<::zp::f04>::max); }(); [&] { @@ -501,6 +483,20 @@ 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"); diff --git a/zp/include/zp/det/mem.ii b/zp/include/zp/det/mem.ii index 89dc192..391f4e1 100644 --- a/zp/include/zp/det/mem.ii +++ b/zp/include/zp/det/mem.ii @@ -4,6 +4,37 @@ 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()) {} @@ -14,9 +45,7 @@ template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr() : _alc(alctyp( ::zp::cpy(this->_buf,oth._buf,oth._len); }*/ -template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::siz const len) { - this->_alc = alctyp {}; - +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; } diff --git a/zp/include/zp/mem b/zp/include/zp/mem index ff289e9..d081dfd 100644 --- a/zp/include/zp/mem +++ b/zp/include/zp/mem @@ -16,6 +16,43 @@ namespace zp { 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: diff --git a/zp/include/zp/prv/flt.h b/zp/include/zp/prv/flt.h index a8212d3..01c68b4 100644 --- a/zp/include/zp/prv/flt.h +++ b/zp/include/zp/prv/flt.h @@ -105,8 +105,8 @@ typedef double zp_f04; #else #define zp_infd (zp_maxvald) #endif -#if zp_prv_hasbltin(__builtin_huge_valil) -#define zp_infdl (__builtin_huge_valil()) +#if zp_prv_hasbltin(__builtin_huge_vall) +#define zp_infdl (__builtin_huge_vall()) #else #define zp_infdl (zp_maxvaldl) #endif diff --git a/zp/include/zp/zp b/zp/include/zp/zp index a4aa49e..f95d4a0 100644 --- a/zp/include/zp/zp +++ b/zp/include/zp/zp @@ -63,63 +63,367 @@ namespace zp { #endif #if zp_std_cxx11 - template<typename typ> struct minval {constexpr static typ val = {};}; - - template<> struct minval<bool> {constexpr static auto val = false;}; - template<> struct minval<char> {constexpr static auto val = zp_minvalc;}; - template<> struct minval<double> {constexpr static auto val = zp_minvald;}; - template<> struct minval<float> {constexpr static auto val = zp_minvalf;}; - template<> struct minval<int> {constexpr static auto val = zp_minvali;}; - template<> struct minval<int long> {constexpr static auto val = zp_minvalil;}; - template<> struct minval<double long> {constexpr static auto val = zp_minvaldl;}; - template<> struct minval<int short> {constexpr static auto val = zp_minvalis;}; - template<> struct minval<char signed> {constexpr static auto val = zp_minvalcs;}; - template<> struct minval<char unsigned> {constexpr static auto val = zp_minvalcu;}; - template<> struct minval<int unsigned> {constexpr static auto val = zp_minvaliu;}; - template<> struct minval<int long unsigned> {constexpr static auto val = zp_minvalilu;}; - template<> struct minval<int short unsigned> {constexpr static auto val = zp_minvalisu;}; - template<> struct minval<wchar_t> {constexpr static auto val = zp_minvalw;}; -#if __cpp_char8_t >= 201811 - template<> struct minval<char8_t> {constexpr static auto val = zp_minvalc8;}; + template<typename typtyp> struct typ { + constexpr static bool isari = false; + constexpr static bool isint = false; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = typ<typtyp>::isari; + constexpr static bool isint = typ<typtyp>::isint; + constexpr static bool isflt = typ<typtyp>::isflt; + 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> { + constexpr static bool isari = typ<typtyp>::isari; + constexpr static bool isint = typ<typtyp>::isint; + constexpr static bool isflt = typ<typtyp>::isflt; + 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> { + constexpr static bool isari = typ<typtyp>::isari; + constexpr static bool isint = typ<typtyp>::isint; + constexpr static bool isflt = typ<typtyp>::isflt; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = false; + constexpr static bool ischr = false; + + constexpr static bool hassgn = false; + + constexpr static bool min = false; + constexpr static bool max = true; + }; + + template<> struct typ<char> { + constexpr static bool isari = false; + constexpr static bool isint = false; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = false; + constexpr static bool isint = false; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = false; + constexpr static bool isint = false; + constexpr static bool isflt = false; + 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 + template<> struct typ<char8_t> { + constexpr static bool isari = false; + constexpr static bool isint = false; + constexpr static bool isflt = false; + 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 + + template<> struct typ<double> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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__ + template<> struct typ<decltype (0.0bf16)> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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 -#if zp_std_cxx11 - template<> struct minval<char16_t> {constexpr static auto val = zp_minvalc01;}; - template<> struct minval<char32_t> {constexpr static auto val = zp_minvalc02;}; - template<> struct minval<int long long> {constexpr static auto val = zp_minvalill;}; - template<> struct minval<int long long unsigned> {constexpr static auto val = zp_minvalillu;}; + +#if __STDCPP_FLOAT128_T__ + template<> struct typ<decltype (0.0f128)> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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 - template<typename typ> struct maxval {constexpr static typ val = {};}; - - template<> struct maxval<bool> {constexpr static auto val = true;}; - template<> struct maxval<char> {constexpr static auto val = zp_maxvalc;}; - template<> struct maxval<double> {constexpr static auto val = zp_maxvald;}; - template<> struct maxval<float> {constexpr static auto val = zp_maxvalf;}; - template<> struct maxval<int> {constexpr static auto val = zp_maxvali;}; - template<> struct maxval<int long> {constexpr static auto val = zp_maxvalil;}; - template<> struct maxval<double long> {constexpr static auto val = zp_maxvaldl;}; - template<> struct maxval<int short> {constexpr static auto val = zp_maxvalis;}; - template<> struct maxval<char signed> {constexpr static auto val = zp_maxvalcs;}; - template<> struct maxval<char unsigned> {constexpr static auto val = zp_maxvalcu;}; - template<> struct maxval<int unsigned> {constexpr static auto val = zp_maxvaliu;}; - template<> struct maxval<int long unsigned> {constexpr static auto val = zp_maxvalilu;}; - template<> struct maxval<int short unsigned> {constexpr static auto val = zp_maxvalisu;}; - template<> struct maxval<wchar_t> {constexpr static auto val = zp_maxvalw;}; -#if __cpp_char8_t >= 201811 - template<> struct maxval<char8_t> {constexpr static auto val = zp_maxvalc8;}; +#if __STDCPP_FLOAT32_T__ + template<> struct typ<decltype (0.0f32)> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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 + +#if __STDCPP_FLOAT64_T__ + template<> struct typ<decltype (0.0f64)> { + constexpr static bool isari = true; + constexpr static bool isint = false; + constexpr static bool isflt = true; + 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 + + template<> struct typ<int> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = true; + constexpr static bool isint = true; + constexpr static bool isflt = false; + 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> { + constexpr static bool isari = false; + constexpr static bool isint = false; + constexpr static bool isflt = false; + 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 + +#if zp_std_cxx20 + template<typename typ> concept arityp = ::zp::typ<typ>::isari; + template<typename typ> concept chrtyp = ::zp::typ<typ>::ischr; + template<typename typ> concept flttyp = ::zp::typ<typ>::isflt; + template<typename typ> concept inttyp = ::zp::typ<typ>::isint; +#endif + #if zp_std_cxx11 - template<> struct maxval<char16_t> {constexpr static auto val = zp_maxvalc01;}; - template<> struct maxval<char32_t> {constexpr static auto val = zp_maxvalc02;}; - template<> struct maxval<int long long> {constexpr static auto val = zp_maxvalill;}; - template<> struct maxval<int long long unsigned> {constexpr static auto val = zp_maxvalillu;}; + template<typename typ> struct isptr {constexpr static bool val = false;}; + + template<typename typ> struct isptr<typ *> {constexpr static bool val = true;}; + template<typename typ> struct isptr<typ * const> {constexpr static bool val = true;}; + template<typename typ> struct isptr<typ * volatile> {constexpr static bool val = true;}; + template<typename typ> struct isptr<typ * const volatile> {constexpr static bool val = true;}; + + template<typename typ> struct isref {constexpr static bool val = false;}; + + template<typename typ> struct isref<typ &> {constexpr static bool val = true;}; #endif - template<typename ityp> struct remqual {using typ = ityp;}; +#if zp_std_cxx11 + template<typename ityp> struct remcv {using typ = ityp;}; - template<typename ityp> struct remqual<ityp const> {using typ = ityp;}; - template<typename ityp> struct remqual<ityp volatile> {using typ = ityp;}; - template<typename ityp> struct remqual<ityp const volatile> {using typ = ityp;}; + template<typename ityp> struct remcv<ityp const> {using typ = ityp;}; + template<typename ityp> struct remcv<ityp volatile> {using typ = ityp;}; + template<typename ityp> struct remcv<ityp const volatile> {using typ = ityp;}; template<typename ityp> struct remref {using typ = ityp;}; @@ -161,152 +465,28 @@ namespace zp { template<typename ltyp,typename rtyp> struct typequ {constexpr static bool val = false;}; template<typename typ> struct typequ<typ,typ> {constexpr static bool val = true;}; +#endif // c++11 - template<typename typ> struct isptr {constexpr static bool val = false;}; - - template<typename typ> struct isptr<typ *> {constexpr static bool val = true;}; - template<typename typ> struct isptr<typ * const> {constexpr static bool val = true;}; - template<typename typ> struct isptr<typ * volatile> {constexpr static bool val = true;}; - template<typename typ> struct isptr<typ * const volatile> {constexpr static bool val = true;}; - - template<typename typ> struct issgn {constexpr static bool val = false;}; - - template<> struct issgn<char signed> {constexpr static bool val = true;}; - template<> struct issgn<double> {constexpr static bool val = true;}; - template<> struct issgn<double long> {constexpr static bool val = true;}; - template<> struct issgn<float> {constexpr static bool val = true;}; - template<> struct issgn<int> {constexpr static bool val = true;}; - template<> struct issgn<int long> {constexpr static bool val = true;}; - template<> struct issgn<int short> {constexpr static bool val = true;}; -#if __STDCPP_BFLOAT16_T__ - template<> struct issgn<decltype (0.0bf16)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT128_T__ - template<> struct issgn<decltype (0.0f128)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT16_T__ - template<> struct issgn<decltype (0.0f16)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT32_T__ - template<> struct issgn<decltype (0.0f32)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT64_T__ - template<> struct issgn<decltype (0.0f64)> {constexpr static bool val = true;}; -#endif #if zp_std_cxx11 - template<> struct issgn<int long long> {constexpr static bool val = true;}; -#endif -#if !zp_uchr - template<> struct issgn<char> {constexpr static bool val = true;}; -#endif -#if !zp_uwchr - template<> struct issgn<wchar_t> {constexpr static bool val = true;}; -#endif - - template<typename typ> struct issgn<typ const> {constexpr static bool val = issgn<typ>::val;}; - template<typename typ> struct issgn<typ volatile> {constexpr static bool val = issgn<typ>::val;}; - template<typename typ> struct issgn<typ const volatile> {constexpr static bool val = issgn<typ>::val;}; - - template<typename typ> struct isusgn {constexpr static bool val = false;}; - - template<> struct isusgn<char unsigned> {constexpr static bool val = true;}; - template<> struct isusgn<char16_t> {constexpr static bool val = true;}; - template<> struct isusgn<char32_t> {constexpr static bool val = true;}; - template<> struct isusgn<int unsigned> {constexpr static bool val = true;}; - template<> struct isusgn<int long long unsigned> {constexpr static bool val = true;}; - template<> struct isusgn<int long unsigned> {constexpr static bool val = true;}; - template<> struct isusgn<int short unsigned> {constexpr static bool val = true;}; -#if __cpp_char8_t >= 201811 - template<> struct isusgn<char8_t> {constexpr static bool val = true;}; -#endif -#if zp_uchr - template<> struct isusgn<char> {constexpr static bool val = true;}; -#endif -#if zp_uwchr - template<> struct isusgn<wchar_t> {constexpr static bool val = true;}; -#endif - - template<typename typ> struct isusgn<typ const> {constexpr static bool val = isusgn<typ>::val;}; - template<typename typ> struct isusgn<typ volatile> {constexpr static bool val = isusgn<typ>::val;}; - template<typename typ> struct isusgn<typ const volatile> {constexpr static bool val = isusgn<typ>::val;}; - - template<typename typ> struct isflttyp {constexpr static bool val = false;}; - - template<> struct isflttyp<double> {constexpr static bool val = true;}; - template<> struct isflttyp<double long> {constexpr static bool val = true;}; - template<> struct isflttyp<float> {constexpr static bool val = true;}; -#if __STDCPP_BFLOAT16_T__ - template<> struct isflttyp<decltype (0.0bf16)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT128_T__ - template<> struct isflttyp<decltype (0.0f128)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT16_T__ - template<> struct isflttyp<decltype (0.0f16)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT32_T__ - template<> struct isflttyp<decltype (0.0f32)> {constexpr static bool val = true;}; -#endif -#if __STDCPP_FLOAT64_T__ - template<> struct isflttyp<decltype (0.0f64)> {constexpr static bool val = true;}; -#endif - - template<typename typ> struct isflttyp<typ const> {constexpr static bool val = isflttyp<typ>::val;}; - template<typename typ> struct isflttyp<typ volatile> {constexpr static bool val = isflttyp<typ>::val;}; - template<typename typ> struct isflttyp<typ const volatile> {constexpr static bool val = isflttyp<typ>::val;}; - - template<typename typ> struct isinttyp {constexpr static bool val = false;}; - - template<> struct isinttyp<char signed> {constexpr static bool val = true;}; - template<> struct isinttyp<char unsigned> {constexpr static bool val = true;}; - template<> struct isinttyp<int> {constexpr static bool val = true;}; - template<> struct isinttyp<int unsigned> {constexpr static bool val = true;}; - template<> struct isinttyp<int long> {constexpr static bool val = true;}; - template<> struct isinttyp<int long long> {constexpr static bool val = true;}; - template<> struct isinttyp<int long long unsigned> {constexpr static bool val = true;}; - template<> struct isinttyp<int long unsigned> {constexpr static bool val = true;}; - template<> struct isinttyp<int short> {constexpr static bool val = true;}; - template<> struct isinttyp<int short unsigned> {constexpr static bool val = true;}; - - template<typename typ> struct isinttyp<typ const> {constexpr static bool val = isinttyp<typ>::val;}; - template<typename typ> struct isinttyp<typ volatile> {constexpr static bool val = isinttyp<typ>::val;}; - template<typename typ> struct isinttyp<typ const volatile> {constexpr static bool val = isinttyp<typ>::val;}; - - template<typename typ> struct isarityp {constexpr static bool val = ::zp::isflttyp<typ>::val || ::zp::isinttyp<typ>::val;}; - - template<typename typ> struct ischrtyp {constexpr static bool val = false;}; - - template<> struct ischrtyp<char> {constexpr static bool val = true;}; - template<> struct ischrtyp<char unsigned> {constexpr static bool val = true;}; - template<> struct ischrtyp<char16_t> {constexpr static bool val = true;}; - template<> struct ischrtyp<char32_t> {constexpr static bool val = true;}; - template<> struct ischrtyp<wchar_t> {constexpr static bool val = true;}; -#if __cpp_char8_t >= 201811 - template<> struct ischrtyp<char8_t> {constexpr static bool val = true;}; -#endif - - template<typename typ> struct ischrtyp<typ const> {constexpr static bool val = ischrtyp<typ>::val;}; - template<typename typ> struct ischrtyp<typ volatile> {constexpr static bool val = ischrtyp<typ>::val;}; - template<typename typ> struct ischrtyp<typ const volatile> {constexpr static bool val = ischrtyp<typ>::val;}; - 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::maxval<typ>::val;}; + 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 // c++11 - -#if zp_std_cxx20 - template<typename typ> concept arityp = ::zp::isarityp<typ>::val; - template<typename typ> concept chrtyp = ::zp::ischrtyp<typ>::val; - template<typename typ> concept flttyp = ::zp::isflttyp<typ>::val; - template<typename typ> concept inttyp = ::zp::isinttyp<typ>::val; #endif #if zp_std_cxx11 @@ -314,7 +494,7 @@ namespace zp { namespace cxx11 { template<typename typ> zp_unseq constexpr auto nulptr() noexcept -> typ * { //static_assert(,""); - return static_cast<typ *>(nullptr); + return zp_nulptr(typ); } } } @@ -322,7 +502,7 @@ namespace zp { #else namespace det { namespace cxx98 { - template<typename typ> zp_unseq typ * nulptr() {return static_cast<typ *>(0x0u);} + template<typename typ> zp_unseq typ * nulptr() {return zp_nulptr(typ);} } } using det::cxx98::nulptr; |