クラス名をコンテナのキーとして何らかの方法で使用することは可能ですか?
同じベースから継承されたクラスのオブジェクトを格納したい。
struct storage {};
struct storagetransform : public storage
{
vec3 position, rotation;
};
struct storageform : public storage
{
unsigned int vertex, texture;
};
ネストされたマップがあります。には、タイプや文字列など...
の特定のクラス名を入力する必要があります。storagetransform
storageform
unordered_map<..., unordered_map<int, storage*> > list;
以下のようにコンテナのオブジェクトにアクセスしたい。
list[storagetransform](1337);
これはどういうわけか可能ですか?さらに、この問題に対するより良いアプローチはありますか?