- Joined
- Apr 28, 2008
- Messages
- 1
- Reaction score
- 0
Hi Folks,
Newly back to c++ after about 6 years so I am extremely rusty. I managed to get the following code to work.
std:air<int, Creator*> initMap[] = {
// sig Id CTor
// ------ -------------------------
std:air<int, Creator*>(1, new CreateOne()),
std:air<int, Creator*>(2, new CreateTwo()),
std:air<int, Creator*>(3, new CreateThree())
};
template<typename T, std::size_t z> std::size_t size(T const (&a)[z]) {
return z;
}
FactoryInstance::FactoryInstance()
: sig2Hdlr(std::map<int, Creator*>(initStdMap,initStdMap+size(initStdMap))),
FactoryBaseClass(&sig2Hdlr)
{
}
Could someone please help me unnderstand this by explaining the following:
template<typename T, std::size_t z> std::size_t size(T const (&a)[z]) {
return z;
}
where the function template is instantiated with size(initStdMap) //where the type of initStdMap is std:air<int, Creator*> * How does it work?
Cheers,
DLT
Newly back to c++ after about 6 years so I am extremely rusty. I managed to get the following code to work.
std:air<int, Creator*> initMap[] = {
// sig Id CTor
// ------ -------------------------
std:air<int, Creator*>(1, new CreateOne()),
std:air<int, Creator*>(2, new CreateTwo()),
std:air<int, Creator*>(3, new CreateThree())
};
template<typename T, std::size_t z> std::size_t size(T const (&a)[z]) {
return z;
}
FactoryInstance::FactoryInstance()
: sig2Hdlr(std::map<int, Creator*>(initStdMap,initStdMap+size(initStdMap))),
FactoryBaseClass(&sig2Hdlr)
{
}
Could someone please help me unnderstand this by explaining the following:
template<typename T, std::size_t z> std::size_t size(T const (&a)[z]) {
return z;
}
where the function template is instantiated with size(initStdMap) //where the type of initStdMap is std:air<int, Creator*> * How does it work?
Cheers,
DLT