指向成员的指针的偏移量 [英] Offset of pointer to member
本文介绍了指向成员的指针的偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
template<class T, typename U> ptrdiff_t foo(T U::* m)
{
// return offset
}
在这种情况下,如何获取字段"m"的偏移量?我宁愿使用编译时表达式.
How I can get the offset of the field 'm' in this context? I would prefer to use am compile-time expression.
在此先感谢您的帮助.最好的问候
Thanks in advance for any help. Best regards
推荐答案
听起来像您在寻找 offsetof()宏.
这篇关于指向成员的指针的偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文