Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Value category of register in C++

I have come across the keyword register in C++ and I am curious about its value category. Are the variables created with the register keyword lvalue (because they can be referenced) or rvalue (because they are stored in a processor register and cannot be accessed by a pointer to their address in memory)?

I’ve studied the basic category values at the link above on the cppreference, but I don’t understand where register variables go according to these definitions.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

register is deprecated or removed depending on the c++ standard version.

If it wasn’t deprecated then it’d be similar to volatile which alters how the compiler treats the variable but it doesn’t change its value category. You can have a volatile lvalue, rvalue etc.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading