Quantcast
Channel: Aras' website
Viewing all articles
Browse latest Browse all 257

Careful With That STL map insert, Eugene

$
0
0
So we had this pattern in some of our code. Some sort of “device/API specific objects” need to be created out of simple “descriptor/key” structures. Think D3D11 rasterizer state or Metal pipeline state, or something similar to them. Most of that code looked something like this (names changed and simplified): // m_States is std::map<StateDesc, DeviceState> const DeviceState* GfxDevice::CreateState(const StateDesc& key) { // insert default state (will do nothing if key already there) std::pair<CachedStates::iterator, bool> res = m_States.

Viewing all articles
Browse latest Browse all 257