From 918dc150f48b4d19cfbf42b5f984b0dedaf7c1da Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 7 Mar 2014 13:26:42 +0000 Subject: [PATCH] added explicit converter between ID types of same size git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7170 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/retroshare/rsids.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libretroshare/src/retroshare/rsids.h b/libretroshare/src/retroshare/rsids.h index ff21cbb64..6063ca934 100644 --- a/libretroshare/src/retroshare/rsids.h +++ b/libretroshare/src/retroshare/rsids.h @@ -53,6 +53,18 @@ template c // explicit t_RsGenericIdType(const unsigned char bytes[]) ; + // Explicit constructor from a different type, checking that the sizes are compatible. + // This is used for conversions such as + // + // GroupId -> CircleId + // GroupId -> GxsId + // + template + explicit t_RsGenericIdType(const t_RsGenericIdType& id) + { + memcpy(bytes,id.toByteArray(),ID_SIZE_IN_BYTES) ; + } + // Random initialization. Can be useful for testing. // static t_RsGenericIdType random()