mirror of https://github.com/PentHertz/srsLTE.git
allow inplace task to be called in const contexts
This commit is contained in:
parent
8d1beb42bd
commit
ee50ed08c2
|
@ -155,7 +155,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
R operator()(Args&&... args) { return oper_ptr->call(&buffer, std::forward<Args>(args)...); }
|
||||
R operator()(Args&&... args) const { return oper_ptr->call(&buffer, std::forward<Args>(args)...); }
|
||||
|
||||
bool is_empty() const { return oper_ptr == oper_table_t::get_empty(); }
|
||||
bool is_in_small_buffer() const { return oper_ptr->is_in_buffer; }
|
||||
|
@ -188,8 +188,8 @@ public:
|
|||
|
||||
private:
|
||||
union {
|
||||
storage_t buffer;
|
||||
void* ptr;
|
||||
mutable storage_t buffer;
|
||||
void* ptr;
|
||||
};
|
||||
const oper_table_t* oper_ptr;
|
||||
};
|
||||
|
|
|
@ -390,6 +390,13 @@ int test_inplace_task()
|
|||
t2();
|
||||
TESTASSERT(v == 5);
|
||||
|
||||
// TEST: task works in const contexts
|
||||
t = l2;
|
||||
auto l3 = [](const srslte::inplace_task<void()>& task) { task(); };
|
||||
v = 0;
|
||||
l3(t);
|
||||
TESTASSERT(v == 6);
|
||||
|
||||
std::cout << "outcome: Success\n";
|
||||
std::cout << "========================================\n";
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue