0

Note: Clause [expr] defines the syntax, order of evaluation, and meaning of expressions.62

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

So, I wonder how to conclude the precedence of these operators according to the International standard?(ignore the cppreference and assume we only have the international standard guide)

#include <iostream>
struct A{
    A(){}
    A& operator+(int index){
      return *this;
    }
};
struct B{
  friend B const& operator << (B const& b,A const&){
     printf("1\n");
     return b;
  }
};
int main(){
    B{} << A{} + 1;
}
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
xmh0511
  • 7,010
  • 1
  • 9
  • 36
  • _I wonder how to conclude the precedence of these operators according to the International standard_ From grammar, ofc. See e.g. https://stackoverflow.com/questions/28592300/precedence-of-operators-in-bnf-grammar https://stackoverflow.com/questions/31600121/how-do-you-write-an-arithmetic-expression-parser-in-javascript-without-using-ev – Language Lawyer Jun 11 '20 at 10:12
  • Another related: https://stackoverflow.com/questions/46341225/comma-operator-in-c11-sequencing/ – aschepler Jun 11 '20 at 12:21
  • @LanguageLawyer I think it does not directly talk the way that summarize these precedence of expression listed in [expr]. – xmh0511 Jun 12 '20 at 01:42

0 Answers0