-
Notifications
You must be signed in to change notification settings - Fork 54
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
strategy for usable const& Mesh objects #391
Comments
@jacobmerson is it not more correct to just admit that One example you can look at is |
@ibaned If the data mentioned is truly meant to be cached and the intermediate data currently stored in the mesh tags is not intended to be directly access via My personal opinion is that making the cache mutable or storing it as a pointer (both options discussed in the c++ core guidelines) gives the cleanest interface and is most obvious about intent. If you split the interface into:
Now we force the user to manage if the data is cached. And that's not particularly friendly since some functions may invalidate the cache data. So, in the user code you must always first check if the cached data exists, then build it if it doesn't, then get it. But, I defer to your experience and what you'll accept here. |
Yea, I think we both understand what the dilemma is here. Do we expose |
@ibaned Hoping to get your perspective on the following as a much more experienced developer.
I did a little bit of work trying to fix up the const correctness of some of the
ask_
functions in the mesh class but hit a bit of a roadblocks because some of the intermediate data is cached in the mesh tags or other arrays in the mesh class. I was thinking about doing the following if/when I have time to allow aconst
reference to mesh to be useable.Cache
struct internal to theMesh
class that holds all of the data/tags that is cached.Cache
mutable so it can be updated in a const reference toMesh
get_tag
functions if the tag name doesn't exist check it against the list of names that were used as internal cache variables and give an error message saying "you are relying on deprecated tags use ask_... instead".The text was updated successfully, but these errors were encountered: