| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
There's std::experimental::propagate_const as pointed out here: llvm/llvm-project#64988 (comment). Looks quite familiar. |
Sorry, something went wrong.
|
We do not have many pointer left in the code so this should be taking a reference now. |
Sorry, something went wrong.
I will tackle references later on - let's start with the pointers which are not supposed to be references yet. |
Sorry, something went wrong.
|
I don't really understand what we achieve with this safe_ptr class. Does it prevent some lifetime issue? |
Sorry, something went wrong.
|
From https://en.cppreference.com/w/cpp/experimental/propagate_const: It treats the wrapped pointer as a pointer to const when accessed through a const access path, hence the name. |
Sorry, something went wrong.
|
The name is misleading though. I think this started as something totally different. Not sure what to call it - constness_ptr, propagate_const_ptr, ptr_wrapper, ...? |
Sorry, something went wrong.
|
I feel a bit skeptic about this spontanously. But yeah some name that indicates that const is propagated sounds good. But at the same time it shouldn't be too long. I wonder how people would feel about a cppcheck checker that tells them about accessing non-const member data using const pointers. Spontanously it seems wrong to do that and I could use that in our selfchecks at least. or do you know a use case when we would want to write such data? I considered such a checker a long time ago but I dropped the idea for some reason. I don't remember why. But I guess it was simply because of limited time and there are plenty of undefined behavior to discover so I rather wanted to work on that. |
Sorry, something went wrong.
https://trac.cppcheck.net/ticket/11127 Not really a use case but something which will cause a lot of const to be dropped if this is fully applied (I think that might include references - not sure about this, it has been too long) is the ErrorLogger usage. On a side note I wonder if there is a simple trick to propagate that a function should not be const. Like adding (void)this; to avoid a function to be static. |
Sorry, something went wrong.
|
I renamed it constness_ptr. Feels awkward but basically describes what it does. |
Sorry, something went wrong.
I like that name better. |
Sorry, something went wrong.
|
I implemented it in simplecpp - see cppcheck-opensource/simplecpp#548. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.