Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I am looking at the node.js documentation for making a module. http://nodejs.org/api/addons.html
I understand templat
I understand template functions and template classes such as
template <class T> void MyTemplateFunction(T a) { a.doSomething(); } ... MyObj mo; MyTemplateFunction <MyObj>(mo);
This code looks a little but like a template but I have never it before:
void init(Handle<Object> exports) { // what is <Object>? }
Handle<Object> is a specification of a template class (as opposed to a template function, which you show above). There is a declaration of
Handle<Object>
template <class T> class Handle { ... };
somewhere in your code or in one of the header files that you included. Essentially, Handle<Object> is a class produced using a Handle template by replacing T with Object throughout the template's code.
Handle
T
Object
Presumably, Handle is a class template with a single type parameter:
template <typename T> class Handle;
and presumably Object is a type.
This instantiates the Handle class template, using Object as the template argument, to give a class; just as your example instantiates the MyTemplateFunction function template, using MyObj as the template argument, to give a function.
MyTemplateFunction
MyObj
Handle<Object>是模板类的规范(与上面显示的模板函数相反)。有一个声明
在您的代码或您包含的某个头文件中的某个位置。本质上,Handle<Object>是一个使用模板生成的类,通过Handle替换整个模板的代码。TObject
It's basically the same thing: exports is declared to be of type Handle<Object>, with Handle being a class template taking one (most likely) type argument. It's probably declared similar to the following:
exports
template<typename T> class Handle{...};