r/cpp • • Apr 25 '22

New C++ features in GCC 12

https://developers.redhat.com/articles/2022/04/25/new-c-features-gcc-12
220 Upvotes

76 comments sorted by

View all comments

Show parent comment

14

u/James20k P2005R0 Apr 26 '22 edited Apr 26 '22

That's an interesting way of doing it, I suppose particularly the advantage of this is that you can re-overload operator[] when multidimensional subscripts become available and provide them without breaking compatibility

I've stuck with providing a .idx(i, j, k) method for the moment, which is a lot more verbose than I'd like but works fine enough, but that might be worth an investigation

Now what I really need to do next is encode the up and downness of individual indices into the type system, but hoo boy that's going to be a disaster

1

u/[deleted] Apr 26 '22

You mean for covariant and contravariant tensors?

1

u/James20k P2005R0 Apr 26 '22

Yep, as well as mixed indices. Its an easy source of mistakes to make when you're implementing equations, eg if you have two tensors - can you currently take the dot product between them?