diff --git a/README.md b/README.md index 9b820b25..3ca42e94 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/m-core.h b/m-core.h index 94c3d5e7..50f7dbfa 100644 --- a/m-core.h +++ b/m-core.h @@ -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__)