Using emplace to generate init_with for shared_ptr:

Equivalent to C++ make_shared)
This commit is contained in:
Patrick Pelissier committed 2023-12-02 13:21:45 +01:00
1 parent 0c8eca893d
commit 2ee40339b0
3 files changed
+50 -1

No files matched your search

+10
View File
@@ -135,6 +135,15 @@ static void test2(void)
shared_int_clear(p1);
}
static void test_emplace(void)
{
shared_mpz_t z;
shared_mpz_init_with_ui(z, 23);
assert ( (*shared_mpz_ref(z))->ptr[0] == 23);
shared_mpz_clear(z);
}
#define MAX_RESSOURCE 10
static void test_ressource(int n)
@@ -223,6 +232,7 @@ int main(void)
{
test1();
test2();
test_emplace();
for(int i = 1; i < MAX_RESSOURCE; i++) {
test_ressource(i);
}