I’m trying to use boost::bind with the std::sort function. I want to bind sort into a function taking no parameters and specify an int array to sort.
I’m running into issues with what to specify as the template parameter when binding sort, if I was using a standard container I would just use std::container<int>::iterator but since I’m using an array I can’t figure out what to use.
Here’s some code that illustrates my compile problem:
const int NUM_VALUES = 100;
int nums[NUM_VALUES];
for (int i=0; i<NUM_VALUES; ++i)
{
nums[i] = NUM_VALUES - i;
}
boost::function<void()> sortHolder = boost::bind(&std::sort<type?>, nums, nums+NUM_VALUES);
Anyone know what template parameters to use here? Any other discussion also welcome.
When you want “iterators” into an array, you use pointers to elements in the array. Such pointers can be used as random access iterators: