I'm trying to create a openGL program. I only get errors in this header file. The error is "error: template-id 'method ' for 'void VertexBufferLayout::method(unsigned int)' does not match any template declaration" I'am clueless of what to do.
I've tried to but the templates in the class with no success.
class VertexBufferLayout
{
private:
std::vector<VertexBufferElement> m_Elements;
unsigned int m_Stride;
public:
VertexBufferLayout()
: m_Stride(0) {}
public:
template <typename T>
void method(T obj)
{
// static_assert(false);
}
inline const std::vector<VertexBufferElement> GetElement() const { return m_Elements; }
inline unsigned int GetStride() const { return m_Stride; }
};
template<>
void VertexBufferLayout::method<float>(unsigned int count)
{
VertexBufferLayout::m_Elements.push_back({ GL_FLOAT, count, false });
VertexBufferLayout::m_Stride += VertexBufferElement::GetSizeOfType(GL_FLOAT);
}
template<>
void VertexBufferLayout::method<unsigned int>(unsigned int count)
{
VertexBufferLayout::m_Elements.push_back({ GL_UNSIGNED_INT, count, false });
VertexBufferLayout::m_Stride += VertexBufferElement::GetSizeOfType(GL_UNSIGNED_INT);
}
template<>
void VertexBufferLayout::method<unsigned char>(unsigned int count)
{
VertexBufferLayout::m_Elements.push_back({ GL_UNSIGNED_BYTE, count, true });
VertexBufferLayout::m_Stride += VertexBufferElement::GetSizeOfType(GL_UNSIGNED_BYTE);
}
The error is "error: template-id 'method ' for 'void VertexBufferLayout::method(unsigned int)' does not match any template declaration"
What type of T
is here, float
or unsigned int
?
VertexBufferLayout::method<float>(unsigned int count)
It's the classic copy-paste error. I guess it must be
VertexBufferLayout::method<float>(float count)
The later line has the same error
void VertexBufferLayout::method<unsigned char>(unsigned int count)
must be
void VertexBufferLayout::method<unsigned char>(unsigned char count)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.