Simplify & factorize the instances of the check against C++

This commit is contained in:
Patrick Pelissier committed 2022-11-30 23:56:29 +01:00
1 parent f25bb73e58
commit bcd0c46e8b
10 files changed
+41 -91

No files matched your search

+1 -10
View File
@@ -25,27 +25,18 @@
LIST_DEF(list_int, int)
// Transform an integer 'i' into a M*LIB base item 'a'
#define TYPE_SET_INT(a, i) (a) = (i)
// Container OPLIST
#define CONT_OPL LIST_OPLIST(list_int, M_OPL_int())
// C++ Base class of the item in the container
#define BASE_CLASS int
// Transform an integer 'i' into a C++ base item 'a'
#define CLASS_SET_INT(a, i) (a) = (i)
// C++ Container class
#define CONT_CLASS std::forward_list<int>
// Compare the M*LIB container a to the C++ container b
#define CMP_CONT(a, b) cmp_cont(a, b)
// Compare the M*LIB base object to the C++ base object
#define CMP_BASE(a, b) assert( (a) == (b) )
void cmp_cont(list_int_t a, std::forward_list<int> b)
{
list_int_it_t ita;
@@ -55,7 +46,7 @@ void cmp_cont(list_int_t a, std::forward_list<int> b)
assert(!list_int_end_p(ita));
const int *b0 = list_int_cref(ita);
int &b1 = *itb;
CMP_BASE(*b0, b1);
assert(*b0 == b1);
itb++;
list_int_next(ita);
}