Re:Returning multiple values from functions in C++
by m_mueller on Sunday March 06, 2016 @09:09PM
(#11236656)
Instead of markers, I like to use typedefs instead. Here's an example how this would look like in a HPC related program. Basically, if you know Fortran, you know where this is coming from.
[ Parent
| on HN ]
Re:Returning multiple values from functions in C++
by Aeolos on Monday March 07, 2016 @02:13AM
(#11237562)
I can't be the only one who finds "INT_VALUE" both superfluous and unnecessarily ugly?
Re:Returning multiple values from functions in C++
by m_mueller on Monday March 07, 2016 @02:18AM
(#11237576)
You're right, I have been thinking about this naming as well. I think in this context, "INT_PARAM" would be better. I like to typedef it because this way it's easier to replace with a hardware specific integer type later on if I decide to do so. Anyways, the "VALUE" naming is coming from Fortran, which is by default pass-by-reference, so you use it to get pass-by-value.
Edit: Thinking about it some more, "INT_VALUE" still makes sense - it makes it clear that this specific symbol should be accessed as a value, not as a pointer. Doing this reminds me that I'm (probably) imposing more register pressure by passing by value. In general I'd probably pass a const int * const pointer here, but in this specific case I needed values because of some CUDA specific limitation.