System::DoTryFinally 方法

System::DoTryFinally(T&&, F&&) method

模拟 C#‘的 try[-catch]-finally 语句行为的单一函数。在使用翻译器选项 finally_statement_as_lambda 设置为 true 翻译 C#‘的 try[-catch]-finally 语句时,该语句会被翻译为调用此方法。

template<typename T,typename F> std::enable_if_t<Details::is_lambda_void_void<T>::value> System::DoTryFinally(T &&tryBlock, F &&finallyBlock)
Parameter描述
T实现被模拟的 try[-catch]-finally 语句中 try[-catch] 部分的函数对象的类型
F实现被模拟的 try[-catch]-finally 语句中 finally 部分的函数对象的类型
ParameterType描述
tryBlockT\&&其主体包含实现被模拟的 try[-catch]-finally 语句中 try[-catch] 部分的函数对象
finallyBlockF\&&其主体包含实现被模拟的 try[-catch]-finally 语句中 finally 部分的函数对象

另见

System::DoTryFinally(T&&, F&&) method

模拟 C#‘的 try[-catch]-finally 语句行为的单一函数。在使用翻译器选项 finally_statement_as_lambda 设置为 true 翻译 C#‘的 try[-catch]-finally 语句时,该语句会被翻译为调用此方法。此重载处理实现 try[-catch]-finally 语句中 try[-catch] 部分的函数对象返回值为 bool 的情况。

template<typename T,typename F> std::enable_if_t<Details::is_lambda_void_boolref<T>::value, bool> System::DoTryFinally(T &&tryBlock, F &&finallyBlock)
Parameter描述
T实现被模拟的 try[-catch]-finally 语句中 try[-catch] 部分的函数对象的类型
F实现被模拟的 try[-catch]-finally 语句中 finally 部分的函数对象的类型
ParameterType描述
tryBlockT\&&其主体包含实现被模拟的 try[-catch]-finally 语句中 try[-catch] 部分的函数对象
finallyBlockF\&&其主体包含实现被模拟的 try[-catch]-finally 语句中 finally 部分的函数对象

另见

System::DoTryFinally(T&&, F&&) method

单个函数模拟 C# 的 try[-catch]-finally 语句的行为。在将 C# 的 try[-catch]-finally 语句翻译为选项 finally_statement_as_lambda 为 true 时,该语句被翻译为调用此方法。此重载处理的情况是,实现 try[-catch] 部分的函数对象的返回值为 bool&。

template<typename T,typename F> std::enable_if_t<Details::is_lambda_nonovoid_boolref<T>::value, std::optional<Details::ResultOf<T, bool &>>> System::DoTryFinally(T &&tryBlock, F &&finallyBlock)
Parameter描述
T实现被模拟的 try[-catch]-finally 语句中 try[-catch] 部分的函数对象的类型
F实现被模拟的 try[-catch]-finally 语句中 finally 部分的函数对象的类型
ParameterType描述
tryBlockT\&&其主体包含实现被模拟的 try[-catch]-finally 语句中 try[-catch] 部分的函数对象
finallyBlockF\&&其主体包含实现被模拟的 try[-catch]-finally 语句中 finally 部分的函数对象

另见