I need to find a way to accomplish what I want below, described in the comments. I am trying to use unique_ptr to do so but not having access to make_ptr I'm at a loss. I'd like to use STL's automatic heap allocators and such for this. I just want the map to be able to have itself as a value, by hook or crook. Since I'm targeting the Arduino SDK (but for 32-bit cpus) I don't think I can use boost based solutions nor use C++14.
#include <memory>
#include <string>
#include <unordered_map>
struct map_value;
struct map_value {
// what I *really* want - works with std::map on GCC i guess
//std::unordered_map<std::string,map_value> value;
// what I'll settle for
std::unordered_map<std::string,std::unique_ptr<map_value>> value;
};
void setup() {
map_value mv;
map_value* pmv2 = new map_value();
// what sorcery do i use below? i don't have std::make_unique nor can I get it
mv.value.insert(std::make_pair("test",pmv2));
}
void loop() {
}
I'll take any alternative that gets me what I want.
Thanks in advance. Sorry if this has been asked before. I looked and could only find solutions involving unique_ptr/make_unique