One day, I wrote this:
double z = data.getField<boost::int32_t>(pointIndex, indexZ);
where of course I really meant this:
double z = data.getField<double>(pointIndex, indexZ);
Note the wrong template type. The problem here is that there's no way to typecheck the return type T is the type we want.
Hobu suggests decltype might help ( http://en.wikipedia.org/wiki/Decltype).
mpg alternatively suggests changing the function from this:
T getField(std::size_t ptIdx, boost::int32_t fieldIdx)
void getField(std::size_t ptIdx, boost::int32_t fieldIdx, T& ret)
Neither suggestion is very palatable, though.
getField is slightly better now (you must pass in the actual dimension instance, not just a dimension position), but this same issue can still happen.
getField is the critical path, however, and any checking in here causes things to be slow. I don't know that we want to try to do type checking.
Closing. get/setField now take in a Dimension object, which while not eliminating the type mismatch thing, lessens it greatly.