I am learning to use map containers, and I can see the logic, we can define the key and the value when we insert any object. I also know that we can insert pairs with these containers and can access the content through .first and .second. However I can not understand this piece of code and need someone to enlighten me if you can:
ClassA.h
#include"ClassB"
#include"ClassC"
class A
{
public:
template<typename T>
void foo1(classC::ID id);
private:
ClassB::Ptr someFunction(classC::ID id);
private:
//map
std::map<class::ID, std::function<classB::Ptr()>> mapName;
}
template<typename T>
void ClassA::foo1(classC::ID id)
{
mapName[id] = [this]() // <-------------- that [this]() ???
{ // Is this calling for that
// function<class::Ptr()> inside map??
//TODO
}
}
ClassB.h
#include"ClassC"
class B
{
typedef std::unique_ptr<ClassB> Ptr;
public:
classB(param1 from other classes , param2 from other classes);
....
}
ClassC.h
namespace States
{
enum ID
{
foo,
foo1,
...
}
}
Thank you