SHOW:
|
|
- or go back to the newest paste.
| 1 | //*** | |
| 2 | La función RF_TaskManager::instance->getTask(id) devuelve RF_Process* | |
| 3 | La idea es que yo ponga getTask<Proceso>("id"); y me recastee lo que le mando.
| |
| 4 | ***// | |
| 5 | ||
| 6 | - | template <class T* = RF_Process*> |
| 6 | + | // Aquí tienes que T es RF_Process o quien sea. Puedes usar T* para referirte a RF_Process* |
| 7 | - | T getTask(string id) |
| 7 | + | template <class T = RF_Process> |
| 8 | T* getTask(string id) // Usa 'getTask(const string& id)' mejor, te evitas una copia de la string | |
| 9 | - | static_assert(std::is_base_of<RF_Process*, T>::value, "T must derive from RF_Process"); |
| 9 | + | |
| 10 | - | return reinterpret_cast<T>(RF_TaskManager::instance->getTask(id)); |
| 10 | + | static_assert(std::is_base_of<RF_Process, T>::value, "T must derive from RF_Process"); |
| 11 | return reinterpret_cast<T*>(RF_TaskManager::instance->getTask(id)); | |
| 12 | } |