
#include <string>
#include <map>
#include <memory>
#include <iostream>

struct Base
{
    virtual void print() = 0;
};

struct Derived0 : Base
{
    void print() override { std::cout << "d0" << std::endl; }
};

struct Derived1 : Base
{
    void print() override { std::cout << "d1" << std::endl; }
};


int main()
{
    
    std::map<std::string, std::unique_ptr<Base>> map;


    map["d0"] = std::make_unique<Derived0>();
    map["d1"] = std::make_unique<Derived1>();

    for(auto& b : map)
    {
        b.second->print();
    }
}