No, I've never actually seen or used it (as far as I can recall, and at least not without sensible typedefs to make it less fubar), but I can contrive an example of what might be a [questionably] valid use:
struct Foo{
struct greater{
bool operator()(Foo const *a, Foo const *b) const{
return a->place > b->place ||
a->place == b->place && a->holder > b->holder;
}
};
int place;
int holder;
};
template<typename T, typename Comparer>
void Sort(T const *unorderedList, int count, T const ***orderedList, Comparer &cmp);
void UseOrderedList(Foo const **orderedList, int count);
int main(){
Foo list[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
Foo const **orderedList;
Sort(list, sizeof list / sizeof *list, &orderedList, Foo::greater());
UseOrderedList(orderedList, sizeof list / sizeof *list);
delete[] orderedList;
return 0;
}
void UseOrderedList(Foo const **orderedList, int count){/*...*/}
template<typename T, typename Comparer>
void Sort(T const *unorderedList, int count, T const ***orderedList, Comparer &cmp){
/*
* The result array stores pointers to the items in the original array.
* This way, the original array is unmodified, and the result array
* doesn't create duplicate items. This makes sense if the objects
* are large and copying them would be slow (another argument against
* in-place sorting), or if duplicating them violates some design
* principle.
*/
*orderedList = new const T*[count];
for(int i = 0; i < count; i++)
(*orderedList)[i] = unorderedList + i;
std::sort(*orderedList, &(*orderedList)[count], cmp);
}
I wouldn't actually do what I've done here. It's just an example of how you could end up with three pointer levels. I can't imagine you running into this kind of scenario very often, though.