Add SWAP as operator.

This commit is contained in:
Patrick Pelissier committed 2017-03-14 20:21:14 +01:00
1 parent ecf5547c1e
commit 6cdad58bd6
2 files changed
+3

No files matched your search

+1
View File
@@ -302,6 +302,7 @@ Other operators are:
* DEL (&obj) : free the allocated uninitialized object 'obj' (default is free). The object is not cleared before being free.
* INIT\_MOVE(objd, objc): Initialize 'objd' to 'objc' by stealing as resources as possible from 'objc' and then clear 'objc'. It is equivalent to calling INIT\_SET(objd,objc) then CLEAR(objc) (but usually way faster).
* MOVE(objd, objc): Set 'objd' to 'objc' by stealing as resources as possible from 'objc' and then clear 'objc'. It is equivalent to calling SET(objd,objc) then CLEAR(objc) or CLEAR(objd) and then INIT\_MOVE(objd, objc).
* SWAP(objd,objc): Swap the object c and object d contains.
* HASH (obj) --> size_t: return a hash of the object (used for hash table). Default is performing a hash of the memory representation of the object.
* EQUAL(obj1, obj2) --> bool: return true if both objects are equal, false otherwise. Default is using memcmp.
* CMP(obj1, obj2) --> int: return a negative integer if obj1 < obj2, 0 if obj1 = obj2, a positive integer otherwise. Default is C comparison operators.
+2
View File
@@ -598,6 +598,7 @@
#define M_INIT_INIT(a) ,a,
#define M_INIT_SET_INIT_SET(a) ,a,
#define M_INIT_MOVE_INIT_MOVE(a) ,a,
#define M_SWAP_SWAP(a) ,a,
#define M_SET_SET(a) ,a,
#define M_MOVE_MOVE(a) ,a,
#define M_CLEAR_CLEAR(a) ,a,
@@ -651,6 +652,7 @@
#define M_GET_INIT_MOVE(...) M_GET_METHOD(INIT_MOVE, M_MOVE_DEFAULT, __VA_ARGS__)
#define M_GET_SET(...) M_GET_METHOD(SET, M_SET_DEFAULT, __VA_ARGS__)
#define M_GET_MOVE(...) M_GET_METHOD(MOVE, M_MOVE_DEFAULT, __VA_ARGS__)
#define M_GET_SWAP(...) M_GET_METHOD(SWAP, M_MOVE_DEFAULT, __VA_ARGS__)
#define M_GET_CLEAR(...) M_GET_METHOD(CLEAR, M_CLEAR_DEFAULT, __VA_ARGS__)
#define M_GET_DEL(...) M_GET_METHOD(DEL, M_DEL_DEFAULT, __VA_ARGS__)
#define M_GET_HASH(...) M_GET_METHOD(HASH, M_NO_DEFAULT, __VA_ARGS__)