c++中this[i]的用法是什么语法?
巴扎黑
巴扎黑 2017-04-17 11:32:46
0
1
438

在webkit中看到一段代码:
class ExecState : public Register { JSValue calleeAsValue() const { return this[JSStack::Callee].jsValue(); } ... }
其中JSStack::Callee是常量,不管是ExecState还是Register都没有对operator[]进行重载,所以想不明白this[JSStack::Callee]这样的用法是什么意思?

巴扎黑
巴扎黑

reply all(1)
伊谢尔伦

This has nothing to do with the overloading of operator[], because this is a pointer to itself, and *this is an instance of ExecState.

Then the question is how to understand it from the C language level. this[JSStack::Callee]Actually *(this + JSStack::Callee). Although I have not understood the code of webkit, I guess that the calling condition of calleeAsValue() is that this instance is in an array (perhaps a stack implemented with an array?), so that code makes sense.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!