When I use a unique_ptr as the return type, I receive compiler error C2280:
'caf::detail::tuple_vals<std::unique_ptr<A,std::default_delete<_Ty>>>::tuple_vals(const caf::detail::tuple_vals<std::unique_ptr<_Ty,std::default_delete<_Ty>>> &)': attempting to reference a deleted function include\caf\detail\tuple_vals.hpp 102
Here's some example code that illustrates the issue (modified from one of the C++ Actor Framework examples):
#include <iostream>
#include "caf/all.hpp"
using namespace caf;
using namespace std;
class A
{
public:
int a;
A(int a)
{
this->a = a;
}
};
using a_type = typed_actor<replies_to<int>::with<unique_ptr<A>>>;
a_type::behavior_type a_behavior(a_type::pointer self)
{
return
{
[self](const int& a) -> unique_ptr<A>
{
return make_unique<A>(5);
}
};
}
void tester(event_based_actor* self, const a_type& testee)
{
self->link_to(testee);
// will be invoked if we receive an unexpected response message
self->on_sync_failure(
[=]
{
aout(self) << "AUT (actor under test) failed" << endl;
self->quit(exit_reason::user_shutdown);
});
self->sync_send(testee, 5).then(
[=](unique_ptr<A> a)
{
if(a->a == 5)
{
aout(self) << "AUT success" << endl;
}
self->send_exit(testee, exit_reason::user_shutdown);
}
);
}