こんにちは。
ちょっとお力をいただきたいのですが、
以下のような、キーは違うのに、値が一緒のmapがあるとします。
static const std::map<int, const char*> test_map = {
{ 100, "hoge" },
{ 200, "hoge" },
{ 300, "hoge" }
};
上記のキーを一つにまとめたいのですが、何かいい方法とかないでしょうか…
static const std::map<int, const char*> test_map = {
{ 100-300, "hoge" }, // こんな感じでキーを一つにまとめたい
};
int main(){
auto it = test_map.find(200);
it->second; // "hoge"
return;
}
以上です。どうかよろしくお願いします。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。