Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper 'using' syntax for pointer-to-member variable

  struct MyStruct {
    typedef int MyStruct::*Ptr;  // my pointer-to-member type
    int foo, bar;
  };

This code works, but I'd like to bring it up-to-date with modern style and replace the typedef with a using. What's the right syntax to use? I've tried a bunch of options and I'm stuck; the only examples I can find are for pointer-to-member-function which is different.

like image 383
StilesCrisis Avatar asked Nov 18 '25 02:11

StilesCrisis


1 Answers

The using syntax just moves the identifier placement, the general case is that

typedef ............. foo ..............;

can be changed to

using foo = .............  .............;

Your case is no exception; the code could be using Ptr = int MyStruct::*;

like image 113
M.M Avatar answered Nov 20 '25 16:11

M.M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!