AZ
Size: a a a
AZ
ПК
template<typename ResultType, typename ExceptionType, typename FunctionType>Хотелось бы сделать так, чтобы туда можно было передавать несколько
inline ResultType RetryOnAnyException(FunctionType func)
{
for (;;)
{
try
{
return func();
}
catch (ExceptionType const& e)
{
}
}
}
ExceptionType
(в идеале variadic template) и чтобы все переданные исключения отлавливались. Как это сделать, не засовывая исключения в одну иерархию?std::exception
, то можно динамик кастом пройтись просто по списку типовCD
template<typename ResultType, typename ExceptionType, typename FunctionType>Хотелось бы сделать так, чтобы туда можно было передавать несколько
inline ResultType RetryOnAnyException(FunctionType func)
{
for (;;)
{
try
{
return func();
}
catch (ExceptionType const& e)
{
}
}
}
ExceptionType
(в идеале variadic template) и чтобы все переданные исключения отлавливались. Как это сделать, не засовывая исключения в одну иерархию?template <typename FunctionType, typename... Exceptions>
struct caller;
template <typename FunctionType, typename Exception1, typename... ExceptionsLeft>
struct caller<Exception1, ExceptionsLeft...> : caller<FunctionType, ExceptionsLeft...> {
operator (FunctionType func) {
try {
return __super::operator()(std::forward<>());
}
catch (Arg1 const&) {
}
};
template<FunctionType>
struct caller<FunctionType> {
}
CD
CD
AZ
AB
CD
AB
AZ
CD
CD
AD
template<typename ResultType, typename ExceptionType, typename FunctionType>Хотелось бы сделать так, чтобы туда можно было передавать несколько
inline ResultType RetryOnAnyException(FunctionType func)
{
for (;;)
{
try
{
return func();
}
catch (ExceptionType const& e)
{
}
}
}
ExceptionType
(в идеале variadic template) и чтобы все переданные исключения отлавливались. Как это сделать, не засовывая исключения в одну иерархию?template<typename ResultType, typename FunctionType>
auto make_handler(FunctionType func) {
return func;
};
template<typename ResultType, typename FirstExceptionType, typename... ExceptionTypes, typename FunctionType>
auto make_handler(FunctionType func) {
return [func = make_handler<ResultType, ExceptionTypes...>(func)] {
for (;;) {
try
{
return func();
}
catch (FirstExceptionType const& e)
{
}
}
};
};
template<typename ResultType, typename... ExceptionTypes, typename FunctionType>
inline ResultType RetryOnAnyException(FunctionType func)
{
auto handler = make_handler<ResultType, ExceptionTypes...>(func);
return handler();
}
AD
ЯФ
ЯФ
ЯФ
AK
ЯФ
ЯФ