The current C ++ standard allows compilers to view the body of a function to obtain information for obtaining a function signature:
template <typename T>
inline auto dereference(T const& pointer) {
return *pointer;
}
And I wonder if the compiler can automatically declare whether a function is guaranteed if this definition can be seen, perhaps with a syntax like this:
void func() noexcept(auto) {
…
}
If possible, this will save a lot of difficulty writing a noexcept declaration, especially when writing templates where functions usually follow their definitions when they first appear:
template <typename T>
void func(T& value) noexcept(
noexcept(value.member_1()) &&
noexcept(value.member_2()) &&
noexcept(value.member_3())
) {
value.member_1();
value.member_2();
value.member_3();
}
template <typename T>
void func(T& value) noexcept(auto) {
value.member_1();
value.member_2();
value.member_3();
}
So, can this feature be included in a future version of ISO / IEC 14882?
source
share