Is it safe (thread-safe) to declare a std::future
as being mutable
since its get()
function changes its state. I assume that it's like std::mutex
which is safe to be made mutable
.
template <typename T>
struct S {
void query() {
m_fut = doAsyncQuery();
}
template <typename L>
void get(L lambda) const {
lambda(m_f.get());
}
mutable std::future<T> m_f;
};