Here\'s what I\'m trying to do:
template struct Model
{
vector vertices ;
#if T has a .normal member
void transform(
This has become way easier with C++11.
template struct Model
{
vector vertices;
void transform( Matrix m )
{
for(auto &&vertex : vertices)
{
vertex.pos = m * vertex.pos;
modifyNormal(vertex, m, special_());
}
}
private:
struct general_ {};
struct special_ : general_ {};
template struct int_ { typedef int type; };
template::type = 0>
void modifyNormal(Lhs &&lhs, Rhs &&rhs, special_) {
lhs.normal = rhs * lhs.normal;
}
template
void modifyNormal(Lhs &&lhs, Rhs &&rhs, general_) {
// do nothing
}
};
Things to note:
decltype and sizeof without needing an object.