diff options
-rw-r--r-- | CHANGELOG.txt | 2 | ||||
-rw-r--r-- | zp/include-private/zp/prv/str | 2 | ||||
-rw-r--r-- | zp/include/zp/det/mem.ii | 12 | ||||
-rw-r--r-- | zp/include/zp/mem | 50 | ||||
-rw-r--r-- | zp/include/zp/zp | 22 | ||||
-rw-r--r-- | zp/include/zp/zp.h | 10 | ||||
-rw-r--r-- | zp/source/any/mem/memsrh.c | 2 |
7 files changed, 59 insertions, 41 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 563f406..18cfe6a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,8 @@ * Bump API version; * Remove arr from dev; +* Make nulptr into a function; + # 1.1.1 * Fix res dtor calls; diff --git a/zp/include-private/zp/prv/str b/zp/include-private/zp/prv/str index fee12e5..6f9ab4f 100644 --- a/zp/include-private/zp/prv/str +++ b/zp/include-private/zp/prv/str @@ -69,5 +69,5 @@ template<typename typ> zp_nothw typ * zp::det::strsrh(typ const* str,typ const c zp_unlik (cunrchr == typ (0x0)) {break;} } - return zp_nulptr; + return ::zp::nulptr<typ>(); } diff --git a/zp/include/zp/det/mem.ii b/zp/include/zp/det/mem.ii index a88d31f..89dc192 100644 --- a/zp/include/zp/det/mem.ii +++ b/zp/include/zp/det/mem.ii @@ -9,7 +9,7 @@ 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) {return;} // Allocation failed. + zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;} // Allocation failed. ::zp::cpy(this->_buf,oth._buf,oth._len); }*/ @@ -22,15 +22,15 @@ template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::siz const } #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;} +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) {return;} + 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;} +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;} @@ -38,7 +38,7 @@ template<typename typ,typename alctyp> bool zp::arr<typ,alctyp>::alc(::zp::siz c this->_len = len; this->_buf = this->_alc(len); - zp_unlik (this->_buf == zp_nulptr) {return true;} // If the allocator does NOT throw exceptions. + zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return true;} // If the allocator does NOT throw exceptions. return false; } @@ -100,5 +100,5 @@ template<typename buftyp,typename valtyp> buftyp * zp::srh(buftyp * buf,valtyp & zp_unlik (*addr == val) {return addr;} } - return zp_nulptr; + return ::zp::nulptr<buftyp>(); } diff --git a/zp/include/zp/mem b/zp/include/zp/mem index 6d44236..ff289e9 100644 --- a/zp/include/zp/mem +++ b/zp/include/zp/mem @@ -17,42 +17,40 @@ namespace zp { }; #if zp_std_cxx11 - namespace dev { - template<typename typ,typename alctyp> class arr { - public: - zp_nothw arr(); - arr(::zp::arr<typ,alctyp> & oth); - explicit arr(::zp::siz len); + 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); + zp_nothw arr(::zp::arr<typ,alctyp> && oth); #endif - zp_nothw ~arr(); + zp_nothw ~arr(); - zp_nothw bool oky() const; + zp_nothw bool oky() const; - zp_nothw typ * ptr(); - zp_nothw typ const* ptr() const; - zp_nothw ::zp::siz len() const; + zp_nothw typ * ptr(); + zp_nothw typ const* ptr() const; + zp_nothw ::zp::siz len() const; - bool alc(::zp::siz len); + bool alc(::zp::siz len); - template<typename valtyp> ::zp::siz fil(valtyp const& val); + template<typename valtyp> ::zp::siz fil(valtyp const& val); - zp_nothw typ * begin(); - zp_nothw typ const* begin() const; - zp_nothw typ * end(); - zp_nothw typ const* end() const; + zp_nothw typ * begin(); + zp_nothw typ const* begin() const; + zp_nothw typ * end(); + zp_nothw typ const* end() const; - zp_nothw typ & operator [](::zp::ptrdif off); - zp_nothw typ const& operator [](::zp::ptrdif off) const; + zp_nothw typ & operator [](::zp::ptrdif off); + zp_nothw typ const& operator [](::zp::ptrdif off) const; - private: - alctyp _alc; - typ * _buf; - ::zp::siz _len; - }; - } + private: + alctyp _alc; + typ * _buf; + ::zp::siz _len; + }; #endif template<typename dsttyp,typename srctyp> zp_iln zp_nothw inline ::zp::cpyres<dsttyp,srctyp> memcpy(dsttyp * zp_prv_rsr dst, srctyp const* zp_prv_rsr src, ::zp::siz const num); // Implement in seperate file. diff --git a/zp/include/zp/zp b/zp/include/zp/zp index b163429..a4aa49e 100644 --- a/zp/include/zp/zp +++ b/zp/include/zp/zp @@ -311,6 +311,25 @@ namespace zp { #if zp_std_cxx11 namespace det { + namespace cxx11 { + template<typename typ> zp_unseq constexpr auto nulptr() noexcept -> typ * { + //static_assert(,""); + return static_cast<typ *>(nullptr); + } + } + } + using det::cxx11::nulptr; +#else + namespace det { + namespace cxx98 { + template<typename typ> zp_unseq typ * nulptr() {return static_cast<typ *>(0x0u);} + } + } + using det::cxx98::nulptr; +#endif + +#if zp_std_cxx11 + namespace det { struct nulopttyp {}; } @@ -318,8 +337,6 @@ namespace zp { template<typename typ> class opt { public: - opt(::zp::opt<typ> const& oth) = default; - opt(::zp::opt<typ> && oth) = default; opt(::zp::det::nulopttyp) noexcept; opt(typ const& val); opt(typ && val); @@ -332,7 +349,6 @@ namespace zp { template<typename funtyp,typename msgtyp> auto exp(funtyp const & fun,msgtyp const & msg) const noexcept -> typ const&; - auto operator =(::zp::opt<typ> const& oth) -> ::zp::opt<typ> & = default; auto operator =(::zp::det::nulopttyp) noexcept -> ::zp::opt<typ> &; auto operator =(typ const& val) -> ::zp::opt<typ> &; auto operator =(typ && val) -> ::zp::opt<typ> &; diff --git a/zp/include/zp/zp.h b/zp/include/zp/zp.h index 95552ac..a31bc04 100644 --- a/zp/include/zp/zp.h +++ b/zp/include/zp/zp.h @@ -317,12 +317,14 @@ typedef decltype (nullptr) zp_nulptrtyp; note, however, that C++11 projects will not get this error, and it is here allowed and valid. */ -#if zp_std_c23 || zp_std_cxx11 -#define zp_nulptr (nullptr) +#if zp_std_c23 +#define zp_nulptr(typ) ((typ *)nullptr) +#elif zp_std_cxx11 +#define zp_nulptr(typ) (static_cast< typ *>(nullptr)) #elif zp_std_cxx -#define zp_nulptr (0x0u) +#define zp_nulptr(typ) (static_cast< typ *>(0x0u)) #else -#define zp_nulptr ((void *)0x0u) +#define zp_nulptr(typ) ((typ *)0x0u) #endif #define zp_unimax ((zp_c02)+0x10FFFFu) diff --git a/zp/source/any/mem/memsrh.c b/zp/source/any/mem/memsrh.c index b3d5071..585c7a7 100644 --- a/zp/source/any/mem/memsrh.c +++ b/zp/source/any/mem/memsrh.c @@ -17,5 +17,5 @@ void * zp_memsrh(void const* const bufptr,char unsigned const val,zp_siz const n zp_unlik (*addr == val) {return (char unsigned *)addr;} } - return zp_nulptr; + return zp_nulptr(void); } |