6

int* foo(); and int& foo();

if you're a

int *foo(); and int &foo();

kinda guy, you're fucking weird. And also wrong

Comments
  • 1
    Haven't dabbled too much in C++, but if both are valid, then it can be reasoned towards both variants (and the third - with a space on both sides of the operator)
  • 1
  • 2
    This. Is. Ampersand!
  • 3
    It's &i64, obviously.
  • 2
    @deadlyRants Based rustacean
  • 8
    It's not my fault you don't live on the greater plane of existence where int *foo() is acceptable.

    Bloody muggles and their int* foo() mentality 🤷‍♂️
  • 2
    @C0D4 It's not a pointer function god dammit!
  • 1
    @12bitfloat but I'm using the data returned from the function as pointer, hence the *s position.

    If I was just declaring an int* X = 5; then thats me saying that X is 5 and assigned at that moment, but from foo() it's collected from somewhere else.

    Get with the times boi!!
  • 1
    Agreed. It's far more readable.

    [var_type] [var_name].
  • 2
    It is bad enough my IDE tries to fix this shit for me. Now it appears both ways because of my code and the auto generated code.

    The function isn't a pointer or reference. It returns that shit.
  • 1
    Whatever clang-format does, I'm so past formatting my code manually.

    Now if I get to setup my own .clang-format it it would be int& foo()
  • 0
    devDuck you, I'm gonna take function pointers.

    ```c
    int() *foo;
    ```
Add Comment