Date: Tue, 20 May 2025 10:15:52 +0000
This is what it reads to me.
You have declared a function with a specific return type but it's definition is unable to fulfill it.
That's by definition an invalid definition.
What you are asking is for a way for compilers to accept invalid definitions.
To me the answer is self-evident, the definition is invalid, no support required.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, May 20, 2025 9:46:19 AM
To: std-proposals <std-proposals_at_[hidden]>
Cc: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Subject: [std-proposals] attribute [[unevaluated]]
Sometimes we write a function without any intention of it ever being
invoked. Consider the following function to get a function's return
type:
template <typename ReturnType, typename... Params>
ReturnType ToReturnType( ReturnType (*)(Params...) )
{
// empty function body
}
The only reason we write a function like this is to use 'decltype' on
its invocation, some thing like:
typedef decltype( ToReturnType(my_function_pointer) ) ReturnType;
Most compilers will warn that the above function doesn't have a return
statement, so I suppress the warning with:
template <typename ReturnType, typename... Params>
ReturnType ToReturnType( ReturnType (*)(Params...) )
{
return std::declval<ReturnType>();
}
It though it might be more intuitive though to mark the function:
template <typename ReturnType, typename... Params>
[[unevaluated]] ReturnType ToReturnType( ReturnType (*)(Params...) ) {}
This would have two effects:
(1) The compiler will refuse to use it in an evaluated context
(2) The compiler won't give a warning/error about a missing return statement
You have declared a function with a specific return type but it's definition is unable to fulfill it.
That's by definition an invalid definition.
What you are asking is for a way for compilers to accept invalid definitions.
To me the answer is self-evident, the definition is invalid, no support required.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, May 20, 2025 9:46:19 AM
To: std-proposals <std-proposals_at_[hidden]>
Cc: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Subject: [std-proposals] attribute [[unevaluated]]
Sometimes we write a function without any intention of it ever being
invoked. Consider the following function to get a function's return
type:
template <typename ReturnType, typename... Params>
ReturnType ToReturnType( ReturnType (*)(Params...) )
{
// empty function body
}
The only reason we write a function like this is to use 'decltype' on
its invocation, some thing like:
typedef decltype( ToReturnType(my_function_pointer) ) ReturnType;
Most compilers will warn that the above function doesn't have a return
statement, so I suppress the warning with:
template <typename ReturnType, typename... Params>
ReturnType ToReturnType( ReturnType (*)(Params...) )
{
return std::declval<ReturnType>();
}
It though it might be more intuitive though to mark the function:
template <typename ReturnType, typename... Params>
[[unevaluated]] ReturnType ToReturnType( ReturnType (*)(Params...) ) {}
This would have two effects:
(1) The compiler will refuse to use it in an evaluated context
(2) The compiler won't give a warning/error about a missing return statement
-- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-05-20 10:15:55