example for initialise looop with random number und string unorderd_map? And can make this as variable im Class priate or Public?
bnadem opened this issue · 3 comments
bnadem commented
i want to initialsie and check (print ) all data exist or not for debug,
serge-sans-paille commented
Can you provide a code sample that somehow explains what you're trying to achieve?
bnadem commented
class TestCase {
public : constexpre frozen:.unordered_map<std::string, item_t> itemnotification;
}
im Constructor i want to initilise data, count of Data is defined from Outside
serge-sans-paille commented
The following is possible and should match your needs. Note that the size of the unordered_map must be fixed (or a template parameter of the class)
#include "frozen/string.h"
#include "frozen/unordered_map.h"
#include <iostream>
struct F {
const frozen::unordered_map<int, int, 3> member;
constexpr F(int x, int y, int z) : member{{x,y}, {y,z}, {z, x}} {}
};
int main() {
constexpr F f(1,2,3);
std::cout << "Map size: " << f.member.size() << "\n";
for(auto const& kv: f.member)
std::cout << kv.first << ": " << kv.second << "\n";
return 0;
}