You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a const class function that checks if a DataReader member has any data ready to be received. The problem is, DataReader::read() itself is not const.
I understand that take will modify the internal state of the buffer, but since read returns a view and won't affect the counter, would it make sense to mark it as const?
Thanks
The text was updated successfully, but these errors were encountered:
Hi @t0ny-peng, unfortunately read too modifies the state of the history cache: it changes the "sample state" and "view state" for the samples/instances in the result. I think that's enough to not be able to mark it const.
It did remind me that I've wanted a peek operation for a long time, one that has no side-effects on the reader or its history cache whatsoever. I've added it in the C API (see cyclonedds#1842); adding it to the C++ API should be trivial (just another set of functions like for read/take) but not something I can do right now, but maybe someone else (or you yourself) can do it.
I have a
const
class function that checks if aDataReader
member has any data ready to be received. The problem is,DataReader::read()
itself is not const.https://github.com/eclipse-cyclonedds/cyclonedds-cxx/blob/master/src/ddscxx/include/dds/sub/detail/DataReader.hpp#L74
I understand that
take
will modify the internal state of the buffer, but sinceread
returns a view and won't affect the counter, would it make sense to mark it asconst
?Thanks
The text was updated successfully, but these errors were encountered: