c++ - equivalence to decltype(*this) from a static method? -
i have macros need access type of current class , away via dry-violating pattern:
struct thisscruct{ int a; double b; //example static method using - purely example - not full usecase static size_t sum_offsets(){ typedef thisstruct selft; return offsetof(selft, a) + offsetof(selft, b); } };
this comes lot use of offsetof
keyword, @ least in own work.
now before lock onto this
not being accessible via static method - realize want know how type thisstruct
in generic/macro friendly way static method context. don't need/want instance , looking way works above without typedeffing selft
.
edit: similar asked in can implement autonomous self
member type in c++? - worried diamond problem forming classes both inheriting accepted answer's self
class.
Comments
Post a Comment