template< class Cmp, class Array> class Sorted;// The type of your parameter.
That type achieves nothing. std::sort doesn't return an instance of Sorted, and nothing prevents me from populating an instance of Sorted with an array that is not, in fact, sorted. So, in my opinion the following two pieces of code are perfectly equivalent: void binary_search(const vector<int> sorted_arr);
void binary_search(const Sorted<Cmp,vector<int>> arr);
Considering these as functions in a program that otherwise uses the mainstream C++ library ecosystem, they are equally likely to be called with an unsorted array.In Idris or probably even in C++ with significant effort, you could create a type that can't represent an unsorted array, but that is, again, an almost research-level endeavour (and adding more complex constraints it will quickly evolve).