这个语句 'p = I.ptr<uchar>(i);' 是做什么的?

What does this statement 'p = I.ptr<uchar>(i);' do?

显然,搜索引擎似乎没有将这个符号“<>”纳入搜索范围,因此谁能向我解释一下这个符号和语句的含义?

对于这个说法,我可以猜到

p = I.ptr<uchar>(i);

p恰好指向I[i]地址

谢谢 :)

它正在调用 class 的成员函数,参数为 i。例如

#include <iostream>

using std::cout;
using std::endl;

class Something {
public:
    template <typename T>
    T do_something(T in) {
        cout << __PRETTY_FUNCTION__ << endl;
        return in;
    }
};

int main() {
    auto something = Something{};
    // <int> not really needed here, the type can be deduced,
    // just here for demonstration purposes
    auto integer = something.do_something<int>(1);
    (void) integer;
}

请注意,为了在模板类型的上下文中执行此操作,您需要在方法调用前加上 template 前缀,如本问题中所述 - Where and why do I have to put the "template" and "typename" keywords?