Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getField() type checking #17

Closed
mpgerlek opened this issue Aug 27, 2011 · 2 comments
Closed

getField() type checking #17

mpgerlek opened this issue Aug 27, 2011 · 2 comments

Comments

@mpgerlek
Copy link
Contributor

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)

to this:

void getField(std::size_t ptIdx, boost::int32_t fieldIdx, T& ret)

Neither suggestion is very palatable, though.

@hobu
Copy link
Member

hobu commented Jun 14, 2012

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.

@hobu
Copy link
Member

hobu commented Aug 28, 2013

Closing. get/setField now take in a Dimension object, which while not eliminating the type mismatch thing, lessens it greatly.

@hobu hobu closed this as completed Aug 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants