0

是否可以扩展文字运算符以返回化合物?

例子:

typedef struct { double a,b; } Pair;
Pair p = (Pair){1.2, 3.4}; // <-- Today: compound literal

/* Hypothetical future Operator: */
Pair operator"" _P(double a, double b) {
  return Pair(a,b);
}
...
Pair p = (1.2, 3.4)_P; // <-- Would it be possible?
4

0 回答 0