开发者

Reverse C++ lookup

I am a "C" programmer that knows just the tiniest bits of C++. I am having a look at some open source C++ code trying to understand some things that it is doing. I can work out most of it but sometimes开发者_开发问答 there is syntax I don't recognise and I'd like to be able to "look up" the meaning of the syntax so I can read just enough to understand that bit of C++. But you can't just type a bunch of symbols into google - or whatever to find out the meaning in C++. Any suggestions of how I can do this in general?

The specific syntax I'm struggling with right now is the following:

void Blah<BOARD>::Generate(SgPoint p)

What is the significance of the <BOARD> in this context? What should I look up in order to understand it?


void Blah<BOARD>::Generate(SgPoint p)

Generate is a member function of a class template Blah .

BOARD is the name of the parameter.

Your class Blah could be like this :

template <typename BOARD>
class Blah
{
   //...some code
   void Generate(SgPoint p);
   //...some more code
};


Blah is most likely a templated class, Generate is a method from this class and this is most likely the first line of the method definition.

Edit: Oh and BOARD is the template parameter (can be type or integral value).


This is the Generate method of the Blah class template specialized for template parameter BOARD.

In other words, what follows is the actual code that gets called when the Blah template is used to process an instance of class BOARD.

Other classes may get processed in a different way if separate specializations exist for them, or via the default non-specialized implementation of Generate, or not at all if there is no default and no specialization for them - in which case, an attempt to call that function will not compile.

There is a short introduction to the topic of template specialization here.


You run into C++ templates - very neat feature!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜