这句话是什么'p = I.ptr <uchar>(i);'怎么办?

时间:2017-07-04 18:24:55

标签: c++ opencv3.0

显然,搜索引擎似乎没有采用此符号'&lt;&gt; '搜索,因此有人可以向我解释这个符号的含义以及声明吗?

对于声明,我猜是

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

p碰巧指向I [i]地址。

谢谢:)

1 个答案:

答案 0 :(得分:0)

它使用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?