sprawdź, czy element istnieje za pomocą enable_if
Oto, co próbuję zrobić:
template <typename T> struct Model
{
vector<T> vertices ;
#if T has a .normal member
void transform( Matrix m )
{
each vertex in vertices
{
vertex.pos = m * vertex.pos ;
vertex.normal = m * vertex.normal ;
}
}
#endif
#if T has NO .normal member
void transform( Matrix m )
{
each vertex in vertices
{
vertex.pos = m * vertex.pos ;
}
}
#endif
} ;
widziałemprzykłady używanieenable_if
, ale nie mogę zrozumieć, jak złożyć wniosekenable_if
do tego problemu, lub nawet jeśli można go zastosować.