It seems that currently I can't use a const reference to initialize ScopedAccess if e.g. I only need read access in some method that's to be called on the mutating thread. This, in turn, doesn't allow marking the method const even though it's only reading from the RealtimeObject, messing with const-correctness. Could this be addressed?
Example:
struct Coeffs {
double a, b, c, d;
};
class Foo {
public:
using RealtimeCoeffs
= RealtimeObject<Coeffs, RealtimeObjectOptions::nonRealtimeMutatable>;
const RealtimeCoeffs& getCoeffs() const noexcept { return coeffs; }
RealtimeCoeffs& getCoeffs() noexcept { return coeffs; }
// bar() should be const, but it's not possible because ScopedAccess can't take
// a const reference
void bar /* const */ {
RealtimeCoeffs::ScopedAccess<ThreadType::nonRealtime> c(getCoeffs());
// Doing something with coeffs, but not modifying them
}
private:
RealtimeCoeffs coeffs;
};