This isn't directly about concepts. Any template placed there would have the same issue.
The first question you should ask yourself is: "Is SpecialCompare
a customization point?".
If it is one (if the user can provide their own overloads), then your approach is flawed, because the rest of your code (not only the concept) might not see the user overloads, depending on the include order. You should switch to a different mechanism, such as:
Replacing it with a class template and specializing it (like
std::hash
)Keeping the function, but making sure all calls go through ADL.
This would require no changes to the code if only the owner of atype could provide
SpecialCompare
for it (in their namespace), buthere it's clearly not the case, because you're trying to provide itforstd::vector
which you don't own.There is a hack to work around this: add a dummy parameter (e.g.
struct tag {};
) of a type declared in your namespace (global namespace in this case, but consider moving this to an actual namespace), which will make ADL consider both your namespace and the type's namespace.
Or, if SpecialCompare
isn't a customization point, just order things the right way (the concept and all templates after all overloads of SpecialCompare
).
In any case, document whether SpecialCompare
is a customization point or not.