c++ - 参数包提取
问题描述
我有一个函数 2,可以使用或不使用第二个参数 == char 来调用它。如果是这样,我想修改那个字符参数。
给定
void function1_caller(int x) {
char ws=7;
function2_modifyArg(x, ws);
}
这有效:
template <typename ... WS>
void function2_modifyArg(int x, WS ... ws) {
function3_end(x, ws ...);
}
简单地放在括号中,已经不起作用了:
template <typename ... WS>
void function2_modifyArg(int x, WS ... ws) {
function3_end(x, (ws ... ));
}
这会导致以下错误:
Syntax error: unexpected token '...', expected declaration
实际上在这里我想修改参数,但我当然得到相同的
Syntax error: unexpected token '...', expected declaration
template <typename ... WS>
void function2_modifyArg(int x, WS ... ws) {
function3_end(x, (ws ... / 3));
}
template <typename ... WS>
void function3_end(int x, WS ... ws) {};
解决方案
推荐阅读
- python - BeautifulSoup Scraper 找不到文本?AttributeError: ResultSet object has no attribute 'find_all'
- loops - Applescript 重复可变次数
- neo4j - Cypher/Neo4j 查询以获取当前节点和其他相关信息
- macos - 无法从插件连接到 NSMachBootstrapServer
- ios - iOS - SwiftUI - 执行异步操作后导航到下一个屏幕
- compiler-construction - ANTLR 符号表中的这些值是什么意思?
- javascript - 带有歌词和时间戳的 API
- unity3d - lerp 持续延迟
- javascript - 否定正则表达式中的多个字符集
- ios - 在函数中使用结构并在 @IBAction (Swift) 中引用它的问题