Commit 3e6557dd authored by Quentin Khan's avatar Quentin Khan
Browse files

Change FOctree forEach* methods to avoid copying functor when not necessary

The methods made a copy of the functor when called. This prevented
retrieving the functor's internal state after the call.

A uniform reference is now used to get a reference when possible and an
rvalue reference otherwise.
parent 9c7d5081
......@@ -1683,9 +1683,10 @@ public:
/**
* @brief forEachLeaf iterate on the leaf and apply the function
* @param function
* @param function Callable object with signature `Ret(LeafClass*)`
*/
void forEachLeaf(std::function<void(LeafClass*)> function){
template<class F>
void forEachLeaf(F&& function){
if(isEmpty()){
return;
}
......@@ -1700,9 +1701,10 @@ public:
/**
* @brief forEachLeaf iterate on the cell and apply the function
* @param function
* @param function Callable object with signature `Ret(CellClass*)`
*/
void forEachCell(std::function<void(CellClass*)> function){
template<class F>
void forEachCell(F&& function){
if(isEmpty()){
return;
}
......@@ -1723,9 +1725,10 @@ public:
/**
* @brief forEachLeaf iterate on the cell and apply the function
* @param function
* @param function Callable object with signature `Ret(CellClass*, int level)`
*/
void forEachCellWithLevel(std::function<void(CellClass*,const int)> function){
template<class F>
void forEachCellWithLevel(F&& function){
if(isEmpty()){
return;
}
......@@ -1746,9 +1749,10 @@ public:
/**
* @brief forEachLeaf iterate on the cell and apply the function
* @param function
* @param function Callable object with signature `Ret(CellClass*, LeafClass*)`
*/
void forEachCellLeaf(std::function<void(CellClass*,LeafClass*)> function){
template<class F>
void forEachCellLeaf(F function){
if(isEmpty()){
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment