How should RHS operators be handled?

未关闭
#100 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
冷清
技术栈
cpp

调研方向

未指定任何实现文件、测试或入口点。首先明确是否应支持右侧运算符,然后将 friend 声明与提议的注解进行比较,并确定反射将如何发现它们。项目为这些运算符确定了语法和行为,即表示完成。

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

描述

Since interfaces are defined as structs, there is not an obvious way for how binary operators should be defined where the interface is the right-hand side operand, e.g.:

struct S {
    friend std::ostream& operator<<(std::ostream& out, const S& self);
};

struct Printable {
    // how should this be specified?
};

Is this something we want to support? If so, how should it be written?

One possibility is to write the friend declaration in Printable, but I do not know if there's a way to discover that via reflection. Another is to use the approach from duck, which uses annotations:

struct Printable {
    [[=rjk::right_side]]
    std::ostream& operator<<(std::ostream& out) const;
};

struct AddableWithInt {
    [[=rjk::both_sides]]
    int operator+(int) const;
};

However this could be considered too complex / not matching STL style. Any thoughts?

主要语言
C++
星标
12
派生
4
平均合并
1 天 11 小时
30 天内合并 PR
15

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

jbcoe/cc-protocol 的其他 Issue

查看 jbcoe/cc-protocol 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

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