在variadic Template function中解析源位置woes
The Position Predicament
Invariably, variadic parameters inhabit the end of the parameter list.由于以下原因,这阻碍了std :: source_location的使用:失败,因为variadic parameters必须驻留。
introduces ambiguity for callers as it interjects an unexpected parameter.
Solution: Embracing Deduction Guides
template
void debug(Args&&... args, const std::source_location& loc = std::source_location::current());
允许这样的呼叫:结论:
通过利用推论指南,C程序员可以无缝地将std :: source_location插入variadic Template函数中,以轻松捕获上下文信息。免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3