Login
You're viewing the discuss.systems public feed.

Replies

  • Jan 15, 2025, 1:18 AM

    @joe @thephd @euneuber more seriously: i can't seem to find it in the video now, but i think there is actually a proposed rule for _Operator() that's says that an operand type cannot be a pointer type..? (so iiuc, the compiler would error on your _Operator(<<) above).

    💬 1🔄 0⭐ 0
  • Jan 15, 2025, 1:24 AM

    @joe @thephd @euneuber ...But i think it might allow:

    _Operator(>>, &, const char, FILE, fputs);

    (the function signature is fputs(const char*, FILE*);)

    ...i think...? And that means that:

    const char *s = "hello";
    FILE *f = fopen(/*...*/);

    *s >> *f;

    would translate to:

    fputs(&*s, &*f);

    💬 1🔄 0⭐ 0
  • Jan 15, 2025, 1:53 AM

    @joe @thephd @euneuber found the relevant bit in the video, starting at about 58:00, in response to a question about pointers:

    [58:45] "[...] the same way you can't override for `int, int`, you can't override it for `int *` or `MyStruct * [...] [A pointer is] still a built-in type, even though it's a pointer to your type."

    So, a compiler would issue an error for:
    _Operator(<<, FILE*, const char *, fputs);

    ...because both operand types are built-in types...

    💬 1🔄 0⭐ 0
  • 💬 2🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • 💬 1🔄 0⭐ 0
  • Jan 15, 2025, 4:53 PM

    @thephd @joe @euneuber TIL that the definition of "lvalue" was modified to "an expression with [...] a complete object type" sometime after C99 (in which the definition didn't mention completeness), thus rendering expressions like &*p ill-formed when typeof(*p) is incomplete

    💬 0🔄 0⭐ 0