From cc6ee3507b972b458a0c7382dff93af12593308d Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sun, 9 Jun 2024 00:14:08 +0200 Subject: [PATCH] Simplifications in old common code --- include/asl/defs.h | 52 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/include/asl/defs.h b/include/asl/defs.h index d7dbf2d..2fc670d 100644 --- a/include/asl/defs.h +++ b/include/asl/defs.h @@ -365,9 +365,7 @@ inline bool myisalnum(char c) void asl_die(const char* msg, int line = 0); - void asl_error(const char* msg); - void os_error(const char* msg); template @@ -398,17 +396,10 @@ inline T max(T a, T b) {if(a>b) return a; else return b;} template inline T min(T a, T b) {if(a -inline void asl_construct(T* p) {new (p) T;} +inline void asl_construct(T* p) {new (p) T();} template inline void asl_construct_copy(T* p, const T& x) {new (p) T(x);} @@ -422,41 +413,10 @@ inline void asl_destroy(T* p) {p->~T();} template inline void asl_destroy(T* p, int n) {T* q=p+n; while(p!=q) {p->~T(); p++;}} -// Placement constructors for pointers -#if !defined _MSC_VER || _MSC_VER > 11600 - -template -inline void asl_construct(T**) {} - -template -inline void asl_construct(T**, int) {} - -template -inline void asl_destroy(T**) {} - -template -inline void asl_destroy(T**, int) {} -#endif - -#define ASL_POD_CONSTRUCT(T) \ -inline void asl_construct(T*) {}\ -inline void asl_construct(T*, int) {}\ -inline void asl_destroy(T*) {}\ -inline void asl_destroy(T*, int) {}\ -inline void asl_construct_copy(T* p, const T& x) {*p = x;} \ -inline void bswap(T& a, T& b) {swap(a, b);} - -ASL_POD_CONSTRUCT(byte) -ASL_POD_CONSTRUCT(signed char) -ASL_POD_CONSTRUCT(char) -ASL_POD_CONSTRUCT(int) -ASL_POD_CONSTRUCT(unsigned int) -ASL_POD_CONSTRUCT(float) -ASL_POD_CONSTRUCT(double) -ASL_POD_CONSTRUCT(short) -ASL_POD_CONSTRUCT(unsigned short) -ASL_POD_CONSTRUCT(Long) -ASL_POD_CONSTRUCT(ULong) +inline void asl_construct(byte*, int) {} +inline void asl_destroy(byte*, int) {} +inline void asl_construct(char*, int) {} +inline void asl_destroy(char*, int) {} template struct IsLess { @@ -477,6 +437,8 @@ struct Pair { T1 first; T2 second; + bool operator==(const Pair& b) const { return first == b.first && second == b.second; } + bool operator!=(const Pair& b) const { return !(*this == b); } }; }