Iterating a TOctree2 within bounds

I’m upgrading my code to use the new TOctree2 type in UE v4.26 (TOctree is deprecated).

Previously I had the following code to iterate over elements within the specified box:

for (FCoverPointOctree::TConstElementBoxIterator<> OctreeIt(*CoverPointOctree, BoundsIn);
	OctreeIt.HasPendingElements();
	OctreeIt.Advance())
{
	octreeElements.Add(OctreeIt.GetCurrentElement());
	count++;
}

TConstElementBoxIterator has been deprecated. Instead I’m trying to achieve the same result using the new FindElementsWithBoundsTest method which has the following signature (from GenericOctree.h):

template<typename IterateBoundsFunc>
inline void FindElementsWithBoundsTest(const FBoxCenterAndExtent& BoxBounds, const IterateBoundsFunc& Func) const

I can’t figure out how to pass an “inline” function as an argument:

CoverPointOctree->FindElementsWithBoundsTest<>(BoundsIn, ***[pass function here]***);

Also, how do you decern the function’s signature from looking at the headers files? These classes are scarcely documented which makes it very hard to work with.

I solved my own problem but poking around in the source code… This is an example of what I was looking for.

    int count = 0;
	TArray<FCoverPointOctreeElement> Elements;

	CoverPointOctree->FindElementsWithBoundsTest(BoundsIn, [&Elements, &count](const FCoverPointOctreeElement& Element)
		{
			Elements.Add(Element);
			count++;
		});

Jason,

Could I trouble you to share a bit more of the associated code? I’ve found mountains of TOctree examples and what not, but next to nothing on TOctree2.