I have just learned C++ for a little bit, and discover some special functions.
Example 1
bool operator<(const B& b1,const B& b2)
bool B::operator<(const B& b2) const
//recognized by std::sort
Example 2
MyIterator C::begin();
MyIterator begin(C& c);
//recognized by range-based loop
As far as I know, those function are specially recognized in C++.
(Furthermore, in each pair, they are somehow recognized in the same manner.)
What are the list of all functions that are recognized as special?
In other words, is there any part in C++ (official) specification that summarizes the list of them + how special they are?
I believe that if I blindly code without this knowledge, I may make some silly mistake, especially when interact with std::
class.
Sorry for a not-so-sensible topic name, but I can't think of a better one.
IMO, following are treated specially in C++:
main()
, which has more than 1 valid syntaxstatic, dynamic, const, reinterpret
) and typeid
begin()
& end()
methods or functions are specially treated while dealing with range based for
loopsstruct A { operator int (); };
Few items might be missing. Not sure, if everything is listed somewhere in standard, next to impossible.
However, your fear for messing up with namespace std
is misplaced. It does contain some standard functions, but unless you don't do using namespace std
, there is no fear of any messing up.