If a class has a function call operator that returns a reference to a container (heavily redacted):
class client_connection {
public:
concurrent_queue<T>& operator()() { return client; }
concurrent_queue<T> client;
};
client_connection
class remote {
public:
void get_version() {
auto d = ... something to generate data ...
client().push(d.begin(), d.end());
}
...
client_connection client;
};
client
remote
remote
unique_ptr
client()->push(d.begin(), d.end());
unique_ptr
client_connection
.get()
client.get()->push(m.begin(), m.end()); // error: ‘class client_connection<unsigned char>’ has no member named ‘push’
unique_ptr
You do it like this
client->operator()().push(m.begin(), m.end());
You need to actually call the operator because you have a pointer. Alternatively, dereference the unique pointer instead:
(*client)().push(m.begin(), m.end());