tags:

views:

59

answers:

2

Hi, What does the line:

template<typename _Tp1, typename _Seq1>
friend bool
operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);

in http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/a01367.html

do?

Why is _Tp1 repeated twice in arguements list? Thanks,

+1  A: 
KennyTM
+3  A: 

That's like asking why in:

int strcmp( const char * a, const char * b );

const char * is repeated twice - there are two things to compare. The _Tp1 template parameter is the type of thing being stored in the stack - both stacks being compared must store the same type.

Please note that reading the Standard Library source is not a good way of learning C++ - you need a good book, such as this one.

anon
From my quick look at the book, it seems that the book does NOT give headers and impl source code. It tells you (in detail) how to use these standard libraries. I know a bit of C++ and wanted to dive into the real source code, to familiarize myself with idioms used etc. Not sure about the approach though.
learnerforever
@learner No, it doesn't give you library source - as I suggested, examining the source for a particular Standard Library implementation is not a good way of learning how to use the library, or about common C++ idioms. A trivial example - the name _Tp1 would be illegal in your own code.
anon
ok, thanks Neil.
learnerforever