gpt4 book ai didi

c++ - 元运算符的优先级是什么...?

转载 作者:可可西里 更新时间:2023-11-01 18:36:18 24 4
gpt4 key购买 nike

元运算符...的优先级是多少?谁的工作是解压模板类型参数包?我想它很低,但它有多低? C++ 标准说:

The precedence of operators is not directly specified, but it can be derived from the syntax.

有人愿意接受挑战吗?当然,...没有出现在 C++03 运算符优先级表中。


好的,如果...不是运算符,究竟是什么决定了 std::forward<Args>(args)...适用于整个序列 std::forward<Args>(args)而不仅仅是 (args) , 例如?

最佳答案

好像不是运算符。来自 N3092(抱歉,我手边没有更新的草稿)

[14.5.3] 4/ A pack expansion is a sequence of tokens that names one or more parameter packs, followed by an ellipsis. The sequence of tokens is called the pattern of the expansion; its syntax depends on the context in which the expansion occurs. Pack expansions can occur in the following contexts:

  • In an initializer-list (8.5); the pattern is an initializer-clause.
  • In a base-specifier-list (10); the pattern is a base-specifier.
  • In a mem-initializer-list (12.6.2); the pattern is a mem-initializer.
  • In a template-argument-list (14.3); the pattern is a template-argument.
  • In a dynamic-exception-specification (15.4); the pattern is a type-id.
  • In an attribute-list (7.6.1); the pattern is an attribute.
  • In a capture-list (5.1.2); the pattern is a capture. [Example:

    template<class ... Types> void f(Types ... rest);
    template<class ... Types> void g(Types ... rest) {
    f(&rest ...); // “&rest ...” is a pack expansion; “&rest” is its pattern
    }

    — end example]

关于c++ - 元运算符的优先级是什么...?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7042858/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com