1 Attachment(s)
Object of Class Template Instantiation
Hello to all, I have a error logger class hierarchy which used utilize the template method pattern.
I would like to create a class template that takes type of ClsErrorLogger class type as template argument which forward the request from class template to the ClsErrorLogger class.
This program is running in a embedded system. I wonder is there any performance increase if i put the class template tplErrorLogger in a namespace and instantiate all the necessary object which is refer in later time.
Code:
namespace mySpace
{
template <class ClsErrorLogger>
class tplErrorLogger
{
public:
void logAll()
{
obj.log();
}
private:
ClsErrorLogger obj;
};
// AFAIK, template instantiation is at compile time but i wonder
// whether the object tempalte instantiation is also at compile time.
// Any performance increament if i do this
tplErrorLogger<ClsErrorLogger> generalErrorLogger;
tplErrorLogger<SessionMngtErrorLogger> sessionMngtErrorLogger;
}
class ClsErrorLogger
{
};
class SessionMngtErrorLogger : ClsErrorLogger
{
};
Please comment.
Thanks.