In short: no—you can’t write a C++20 concept that guarantees “this free function actually has a body somewhere” rather than merely a prototype. Concepts only inspect type- and expression-validity at compile time, they do not perform link-time checks for the presence of a function definition.
Why it won’t work:
A concept’s requires-expressions live in an unevaluated context.
cpp
template<auto F>
concept HasAddress = requires {
{ &F }; // must be well‐formed, but does *not* ODR-use F
};
Even though you’re taking &F, the language treats that as an unevaluated operand inside a concept, so no real “address take” ever happens, and you won’t get a link error if the definition is missing.
There is simply no trait or mechanism in the language that says “this symbol was fully defined.” You can check that it’s declared, you can even try to call it in a non-concept context (and if the definition is missing you’ll get a linker error), but your concept can’t force that.
Workarounds
• Require a call in a normal template
If you actually call the function in the body of a template, and it has no definition, you will get a linker error:
cpp
template<auto F, class... Args>
void invoke(Args&&... args)
{
// This is a *real* ODR‐use. Missing definition → link error.
(F)(std::forward<Args>(args)...);
}
Downside: the error only surfaces at link time, not when you check the concept.
• Use function objects instead
If you wrap your logic in a struct or lambda, you can define .operator() inline, and then write a concept that checks std::invocable<T,Args...>. At least you know that the definition for operator() is right there in the translation unit.
• Re-think the interface
Ask yourself what you really need:
– Do you need to call it immediately? Then just call it.
– Do you need to inspect it in some meta-way? Maybe pass it as a template parameter only after you’ve already compiled it in the TU that defines it.
In practical terms: C++ concepts are about “does this type/expression make sense?”; they can’t reach out and prove “the linker will find a body for that function.” You’ll have to enforce that with ordinary calls (ODR-use) and let the linker do its job.