I have this structure:
struct S_SWAP_TALK
{
S_TALK_INFO* pHomeTalk{};
S_AWAY_TALK* pAwayTalk{};
};
And, I have this std::map:
std::map<UINT, S_SWAP_TALK> m_mapSwapTalks;
At the moment, I have populating the map like this:
S_SWAP_TALK sSwapTalk{};
sSwapTalk.pAwayTalk = &sAwayTalk;
m_mapSwapTalks[menuItemId] = sSwapTalk;
or
S_SWAP_TALK sSwapTalk{};
sSwapTalk.pHomeTalk = &sPTI;
m_mapSwapTalks[menuItemId] = sSwapTalk;
Is it possible to simplify this code so that I don't need to ddeclare the S_SWAP_TALK structure as a variable? Eg:
m_mapSwapTalks[menuItemId] = ...;
With C++20 you can write:
With earlier versions, you can write: