Thanks for the replies.
Both replies would have been useful, if I were interested in using the standard library's mechanisms for checking if a container is sortable.
However, in this case, in fact I am not.
The sample code I had originally posted is from Stroustrup's book, viz:
1 2 3 4 5 6 7 8 9 10
|
template<typename Cont>
void sort(Cont& c)
{
/// ...
static_assert(Estd::Sortable<Estd::Iterator<Cont>>(),
"sort(): Cont argument not Sortable");
std::sort(begin(c), end(c));
}
| |
Thus, for this example, I am particularly interested in how to code (the interface) of the Estd::Sortable<Estd::Iterator<Cont>>() function. I am not interested in the semantics of the function, just the function interface.
As you can see, if the call is syntactically correct, the 2 type functions must be of the following pattern:
1 2 3 4 5 6 7 8 9 10 11
|
template<typename T>
constexpr typename T::iterator Estd::Iterator()
{
return T::iterator;
}
template<typename T>
constexpr bool Estd::Sortable()
{
return true; /// dummy implementation
}
| |
However, it doesn't work and instead gives a "template argument deduction/substitution failed" error.
Thus, let me restate the pattern of the problem:
Assuming it is possible to write a function call S<I<T>>, where T is a type, and S<T> and I<T> are function templates, how can we code the interfaces of the S<T> and I<T> function templates?
It is really a query about syntax. I'm not interested in the sorting per se.
I hope that clarifies the query.
Thanks.