Download

Renaming Key and Value of a TMap iterator

A lot of stl is being used in my project so I started removing stl

For example, I would like to wrapper the below code with TMap


.h
std::map<uint32, FMyData> Datas;

.cpp
Datas.clear();

for ( auto& data : Datas )
{
data.second.DoSomething();
}

I only want to change the tmap declaration to minimize client source modification.


template<typename KeyType, typename ValueType>
class TPairWrapper : public TTuple< KeyType, ValueType >
{
public:
TPairWrapper( const TTuple<KeyType, ValueType>& InPair ) : TTuple<KeyType, ValueType>( InPair ), first( InPair.Key ), second( InPair.Value ) {}

public:

KeyType first;
ValueType second;
};

template<typename KeyType, typename ValueType>
class MyTMap : public TMap< KeyType, ValueType >
{
public:
void clear() { Empty(); }
};

.h
MyTMap<uint32, FMyData> Datas;

.cpp

Datas.clear();

for ( auto& data : Datas )
{
data.second.DoSomething(); // I don't know how to wrap this part
}

please help

Nuke it from orbit. It’s the only way to be sure.

Joking aside, replace second with Value.