arduino / arduino/ArduinoCore-API

String relational operators are members.

未关闭
#86 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
306
派生
150
PR 合并指标
30 天内没有已合并 PR

描述

Member relational operators are no good because they cause the lhs and rhs to be treated differently. This causes problems such as making == appear non-commutative. Such as:

```c++
void setup() {
String("hi") == "world";
"world" == String("hi");
}
```

```
sketch_jan19a:3: error: no match for 'operator==' (operand types are 'const char [6]' and 'String')
"world" == String("hi");
^
exit status 1
```

It would be less user-surprising to bring these operators out of the class.

I propose defining them at namespace scope as symmetric pairs of operators, between a String on one side, and everything String accepts as an implicit conversion on the other side, per:
http://en.cppreference.com/w/cpp/string/basic_string/operator_cmp

贡献指南

这个仓库没有索引到贡献指南

调研方向

使用 issue 中的两个 C++ 表达式作为首次复现,然后定位 ArduinoCore-API 中 String 的关系运算符声明。比较两种操作数顺序并检查现有的 String 行为;完成的标准是等价比较能够编译并以对称方式运行,同时覆盖报告的案例。

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp
领域
api, embedded-iot
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。