corey taylor wrote:
Morten,
Yes, you could even write the keyword 'typename' in the for statement.
Did you read the 3rd C++ bullet at http://gcc.gnu.org/gcc-3.4/changes.html?
Basically, it is saying that any type from a template parameter, must be explicitly marked as such with the 'typename' keyword.
corey
Hi List, Hi Corey: the URL says:
/****/
You must now use the typename and template keywords to disambiguate dependent names, as required by the C++ standard.
// Use 'template' to tell the parser that B is a nested // template class (dependent on template parameter T), and // 'typename' because the whole A<T>::B<int> is // the name of a type (again, dependent).
typename A<T>::template B<int> b;
b.callme();
/*****/
sure, Corey, this was indeed helpful. I haven't tried all it says, but now I know where to find the interesting 'typename' part of the C++ documentation.
however, I would still prefer to use my old gcc 3.3.2
What I don't quite understand is this :
g++ -o foo.out sourcecode.cpp
-L /opt/sfw/gcc-3/lib/
-R /opt/sfw/gcc-3/lib/
-lstdc++
I read on the net in the excellent solarisx86 mailing list that I had to use the -L -R flags.
http://groups.yahoo.com/group/solarisx86/message/18055
where can I find more documentation about this solarisx86 specific issue ?
Is it likely that other libraries can be used ?
I also prefer to compile with the flags -ansi -pedantic -Wall for both C and C++ code.
===
It is not important but I did not succeed in writing the for statement with any typename
typename map<T, A>::const_iterator ci;
for ( ci = v.begin();
could not be changed to
map<T, A>::const_iterator ci;
for ( typename ci = v.begin();
best regards
Morten Gulbrandsen
On Mon, 07 Feb 2005 19:54:58 +0100, Morten.Gulbrandsen
<f1000mhz@xxxxxxxx> wrote:
corey taylor wrote:
Moten,
I think this is *best* explained by the gcc release notes for 3.4
This release is the first one to throw this as an error and not a warning as you can produce in gcc 3.3.
http://gcc.gnu.org/gcc-3.4/changes.html
Under C++. The third bullet.
The summary is that you need to explicitly specify that const_iterator with the 'typename' keyword before it.
corey
Thanks, this should be correct ?
// // Display map properties // template<class T, class A> void ShowMap(const map<T, A>& v) {
typename map<T, A>::const_iterator ci;
for ( ci = v.begin(); ci != v.end(); ++ci) cout << ci->first << ": " << ci->second << "\n";
cout << endl; }
instead of incorrect :
template<class T, class A>
void ShowMap(const map<T, A>& v) { for (map<T, A>::const_iterator ci = v.begin(); // line 107
/*=======================!!=========================*/
ci != v.end(); ++ci) cout << ci->first << ": " << ci->second << "\n";
cout << endl;
}
if this is correct then I have inderstood it,
'typename' was greek to me
best regards
Morten Gulbrandsen