ciao.
Ho una classe con una funzione template che vorrei
specializzare a seconda che :
1)eseguita da qualsiasi parametro template tranne CEmpty
2)eseguita dal parametro template = a CEmpty
so specializzare le classi template ma non le funzioni , chiedevo anche se è possibile specializzare per tutti i tipi tranne CEmpty in modo che tutte le chiamate alla funzione che non hanno CEmpty come parametro template eseguano un codice comune (quello di Create nell esempio).codice://questa è la classe , non è un template ma se serve renderla tale si puo fare, anche //se vorrei capire bene le possibilità e le differenze tra specializzazione di //funzioni template e di classi template, sul diversi libri non l'ho capita bene , quindi sono //qui a chiedere class CVboCreator { public: CVboCreator(void){}; ~CVboCreator(void){}; void GenAndBindVertexArray(GLuint& vertexArrayObject) { glGenVertexArrays(1, &vertexArrayObject); glBindVertexArray(vertexArrayObject); } //questa è la funzione, vorrei che eseguisse questo per tutti i parametri //template tranne CEmpty che non deve fare niente , ma essere solo richiamata //ed eseguita(esegue nessun codice ma esegue) template<class Data> bool Create(GLuint& vertexArrayObject, GLuint& vertexBufferObject, Data* VBOData) { glGenBuffers(1, &vertexBufferObject); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject); glBufferData(GL_ARRAY_BUFFER, sizeof(*VBOData), glm::value_ptr(*VBOData), GL_STATIC_DRAW); return true; } };
grazie.

Rispondi quotando