Sup~
Just want to ask several questions with the following code:
- Is managers_ declared correctly?
template static std::unordered_map*> managers_;
- If managers_ is declared correctly. How do we add elements into it? The current way I have is incorrect.
managers_[manager->GetType()] = manager;
managers_.insert(std::make_pair*>
It results to these errors
Severity Code Description Project File Line Suppression State Error C1903 unable to recover from previous error(s);
Severity Code Description Project File Line Suppression State Error C3245 'managers_': use of a variable template requires template argument list
- Does anyone know the cause of this? Any solutions?
Thank you in advance. ^ ^
struct ManagerType
{
std::string name;
};
template<typename T>
class Manager :
public Singleton<T>
{
protected:
Manager();
Manager(const Manager&) = delete;
virtual ~Manager();
protected:
Manager& operator=(const Manager&) = delete;
public:
virtual ManagerType* GetType() const;
};
class LogManager :
public Manager<LogManager>
{
private:
friend class System;
public:
static ManagerType* GetStaticType();
private:
LogManager();
LogManager(const LogManager&) = delete;
virtual ~LogManager();
private:
LogManager& operator=(const LogManager&) = delete;
};
class System :
public Singleton<System>
{
public:
System();
System(const System&) = delete;
virtual ~System();
public:
System& operator=(const System&) = delete;
public:
template<typename T>
void PushManager(Manager<T>* manager)
{
managers_[manager->GetType()] = manager;
managers_.insert(std::make_pair<manager::ManagerType*, Manager<T>*>(manager->GetType(), manager));
}
private:
template<typename T>
static std::unordered_map<ManagerType*, Manager<T>*> managers_;
};
Aucun commentaire:
Enregistrer un commentaire