add the pushWithCnv method to the HeterogenMap class

This commit is contained in:
2026-07-15 18:33:42 +03:00
parent 21f3ff9a4c
commit 117765ddd7
2 changed files with 84 additions and 0 deletions

View File

@@ -128,5 +128,31 @@ int main()
std::println("hmap_move.size() = {}", hmap_move.size());
std::println("hmap_copy.size() = {}", hmap_copy.size());
std::println("\n{:*^80}", " hmap with custom conv funcs ");
hmap.pushWithCnv(
"str_cst", std::string{"ABC"}, [&s](std::string const& v) { return s.c_str(); },
[&s](const char* p) {
s = p;
return s;
});
auto ptr = hmap.get<const char*>("str_cst");
if (ptr) {
std::println("ptr = {}", ptr.value());
} else {
std::println("cannot get PTR");
}
// std::string pp = "EEEE";
// auto err = hmap.set("str_cst", pp.c_str());
const char* pp = "EEEE";
auto err = hmap.set("str_cst", pp);
if (err) {
std::println("cannot set 'str_cst'");
} else {
std::println("s = {}", s);
}
return 0;
}