[dcl.attr.noreturn] can be used to mark that a function doesn't return.
[[ noreturn ]] void f() {
throw "error";
}
Is [[noreturn]]
part to the identity/signature of a function? can one detect that a function is noreturn
at the time of compilation?
For example,
static_assert(is_noreturn(f));
In case it is not, should I adopt a convention an define a tag struct?
struct noreturn_{noreturn_()=delete;};
...
[[noreturn]] noreturn_ f(){throw "error";}
"signature" has a very precise definition. Well, several, depending on the kind of thing you are talking about:
Attributes are not in any of them.
[[noreturn]]
is also not part of the type. It appertains to the function, not its type.No. The rule the committee established for attributes is that "compiling a valid program with all instances of a particular attribute ignored must result in a correct interpretation of the original program". That rule would not hold if you can programmatically detect an attribute's presence.
It's unclear what use such a tag would have.