C++ 有没有一种方法可以使用C++;17重表达?
假设我有这个模板类C++ 有没有一种方法可以使用C++;17重表达?,c++,c++17,expression,fold,C++,C++17,Expression,Fold,假设我有这个模板类 template <typename... TMessageHandler> class message_handler_set { public: static bool call_handler(const MessageType& command) { // Call each TMessageHandler type's 'call_handler' and return the OR of the return
template <typename... TMessageHandler>
class message_handler_set
{
public:
static bool call_handler(const MessageType& command)
{
// Call each TMessageHandler type's 'call_handler' and return the OR of the returns.
}
};
是否可以使用折叠表达式实现此功能?语法如下:
static bool call_handler(const MessageType& command)
{
return (... || TMessageHandler::call_handler(command));
}
您是否尝试过返回(TMessageHandler::call_handler(command)| |…)?(当然,您需要将
message\u handler\u set
更改为variadic。)谢谢,这很好。
static bool call_handler(const MessageType& command)
{
return (... || TMessageHandler::call_handler(command));
}