Hacker News new | past | comments | ask | show | jobs | submit login

This reasoning seems to me similar to how declaring a pointer in e.g. C works: many beginners write

    int* a, b;
And think that this constructs two pointers-to-integer. In fact, it constructs one pointer and one plain integer. A better (equivalent) way to write it is

    int *a, b;
You're not declaring variables of type

   int*
You're saying that b is an int and

    *a 
Is an int, where the asterisk means "the dereferenced a"!



Beginners and also C++ programmers, expert and beginner alike. Even though it’s just as misleading in C++. This:

    int a = 0;
    int& x = a, y = a;
declares x to be a reference, but y an independent variable. Similarly, a template parametrised by a variadic pack of function pointers is declared thus:

    template <void (*...x)(void)>
It’s a good thing I don’t work in C++ too often, because my forehead would have probably sustained noticeable injury from all the facepalming each time I see ‘int& x’ instead of ‘int &x’ and ‘typename... T’ instead of ‘typename ...T’.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: