Ever so once in a while, I see stuff like this, remember my C++ days, and feel excited about trying to write more C++… and then I snap out of it, like remembering why you broke up with an ex-lover in the first place.
No, but seriously, this is great stuff, and I am always happy to see gcc get better. The next time I write C++, which I’ll try to do for GNU Octave, I’ll be very grateful for better diagnostics. I already am, since gcc keeps getting better and better.
According to godbolt’s trunk gcc, it is not smart enough:
<source>: In function 'void test(foo*)':
<source>:20:12: error: 'int foo::m_x' is private within this context
if (ptr->m_x >= 3)
^~~
<source>:13:7: note: declared private here
int m_x;
^~~
Compiler returned: 1
Ever so once in a while, I see stuff like this, remember my C++ days, and feel excited about trying to write more C++… and then I snap out of it, like remembering why you broke up with an ex-lover in the first place.
No, but seriously, this is great stuff, and I am always happy to see gcc get better. The next time I write C++, which I’ll try to do for GNU Octave, I’ll be very grateful for better diagnostics. I already am, since gcc keeps getting better and better.
A lot of good stuff, reading C++ errors is like learning an extra language on top of the C++ language, I can’t wait to try it out.
That one is interesting! I wonder how smart it is.
For instance in the following example:
I wonder if the compiler would be able to figure out that m_x is accessible via
ptr->get_coordinates().first?Hah, you’re also cross-posting to HN as I am.
:) yes, the author was able to reply on HN and even took time to open a suggestion on GCC’s bugzilla
According to godbolt’s trunk gcc, it is not smart enough:
The template type differences stuff looks great; those pages upon pages of template errors that you can get for a simple typo are so overwhelming.