1

With reference to offsetof

would appreciate a simpler explanation of the following:

The expression offsetof(type, member) is never type-dependent and it is value-dependent if and only if type is dependent.

melpomene
  • 84,125
  • 8
  • 85
  • 148
user9196120
  • 381
  • 3
  • 9
  • 3
    Basically, it says that the type of `offsetof` invocation is always the same regardless of its arguments; but the value depends on `type`, which is significant in a template when `type` depends on template arguments. – Igor Tandetnik Apr 19 '18 at 04:58
  • Or when, and if, the member is overloaded and the type depends on its value. (which seems like it would be limited to the template case you describe) – David C. Rankin Apr 19 '18 at 05:01
  • If you're using `offsetof` you're writing hackerhead C code. In C++ `offsetof` has many problems, and you should use a pointer-to-member instead. – Pete Becker Apr 19 '18 at 12:28

0 Answers0