Help! I am writing an image processing package. For
one constructor, I allow creating an image from a
map of points and color values. The points are
of a "position" class and the colors are just a
vector. It starts thusly:
template <class T>
image<T>::image(map<position<int, vector<T >& in_map){
cerr<< "***** ***** ***** ***** ***** *****\n";
cerr<< "making image from map \n";
cerr<< "***** ***** ***** ***** ***** *****\n";
// make an iterator into the input map
map< position<int>, vector<T::iterator mapit;
mapit = in_map.begin();
.... do stuff with the iterator
}
Oddly, this compiled just fine a month or so ago before I
upgraded my OS from Mandriva 2006 to Mandriva 2007.
Now, however, I get the error:
constructors.cpp: In constructor 'image<T>::image(std::map<position<int>, std::vector<T, std::allocator<_CharT, std::less<position<int, std::allocator<std::pair<const position<int>, std::vector<T, std::allocator<_CharT >&)':
constructors.cpp:127: error: expected `;' before 'mapit'
constructors.cpp:128: error: 'mapit' was not declared in this scope
Even more oddly, to me, if I add another iterator, I don't get
an additional error:
template <class T>
image<T>::image(map<position<int, vector<T >& in_map){
cerr<< "***** ***** ***** ***** ***** *****\n";
cerr<< "making image from map \n";
cerr<< "***** ***** ***** ***** ***** *****\n";
// make an iterator into the input map
map<char,int>::iterator testiterator;
map< position<int>, vector<T::iterator mapit;
mapit = in_map.begin();
.... do stuff with the iterator
}
gives the same error -- it doesn't choke on testiterator.
Configuration:
HP Pavilion zd8000 Pentium4 laptop
Mandriva 2007 linux
gcc version 4.1.1 20060724 (prerelease) (4.1.1-3mdk)
Any pointers would be appreciated!!
Thanks,
billo 5 1978
Bill Oliver wrote:
Help! I am writing an image processing package. For
one constructor, I allow creating an image from a
map of points and color values. The points are
of a "position" class and the colors are just a
vector. It starts thusly:
template <class T>
image<T>::image(map<position<int, vector<T >& in_map){
cerr<< "***** ***** ***** ***** ***** *****\n";
cerr<< "making image from map \n";
cerr<< "***** ***** ***** ***** ***** *****\n";
// make an iterator into the input map
map< position<int>, vector<T::iterator mapit;
replace the line above with:
typename map< position<int>, vector<T::iterator mapit;
mapit = in_map.begin();
....
Any pointers would be appreciated!!
Types from dependant classes need a "typename" specifier.
In article <12*************@corp.supernews.com>,
Bill Oliver <bi***@radix.netwrote:
> Help! I am writing an image processing package..
Here's some further data. The error goes away, and
the program runs fine if I replace:
map<position<int>,vector<T::iterator mapit;
with
map<position<int>,vector<float::iterator mapit;
even though T is set to float in the calling routine.
billo
In article <45**********************@per-qv1-newsreader-01.iinet.net.au>,
Gianni Mariani <gi*******@mariani.wswrote:
> Types from dependant classes need a "typename" specifier.
Thank you!!!! That was exactly the problem. Doh.
Now I am wondering why it *used* to work OK.
billo
Bill Oliver wrote:
>
Help! I am writing an image processing package. For
one constructor, I allow creating an image from a
map of points and color values. The points are
of a "position" class and the colors are just a
vector. It starts thusly:
template <class T>
image<T>::image(map<position<int, vector<T >& in_map){
cerr<< "***** ***** ***** ***** ***** *****\n";
cerr<< "making image from map \n";
cerr<< "***** ***** ***** ***** ***** *****\n";
// make an iterator into the input map
map< position<int>, vector<T::iterator mapit;
typename map< position<int>, vector<T::iterator mapit;
mapit = in_map.begin();
.... do stuff with the iterator
}
Oddly, this compiled just fine a month or so ago before I
upgraded my OS from Mandriva 2006 to Mandriva 2007.
Now, however, I get the error:
constructors.cpp: In constructor 'image<T>::image(std::map<position<int>,
std::vector<T, std::allocator<_CharT, std::less<position<int,
std::allocator<std::pair<const position<int>, std::vector<T,
std::allocator<_CharT >&)': constructors.cpp:127: error: expected
`;' before 'mapit' constructors.cpp:128: error: 'mapit' was not declared
in this scope
Even more oddly, to me, if I add another iterator, I don't get
an additional error:
template <class T>
image<T>::image(map<position<int, vector<T >& in_map){
cerr<< "***** ***** ***** ***** ***** *****\n";
cerr<< "making image from map \n";
cerr<< "***** ***** ***** ***** ***** *****\n";
// make an iterator into the input map
map<char,int>::iterator testiterator;
map< position<int>, vector<T::iterator mapit;
mapit = in_map.begin();
.... do stuff with the iterator
}
gives the same error -- it doesn't choke on testiterator.
You only need the typename keyword for dependent names. Since
map<char,int>::iterator does not involve the template paramenter T, it is
not a dependent name, hence no "typename" is needed.
Best
Kai-Uwe Bux
Bill Oliver wrote:
In article <45**********************@per-qv1-newsreader-01.iinet.net.au>,
Gianni Mariani <gi*******@mariani.wswrote:
>> Types from dependant classes need a "typename" specifier.
Thank you!!!! That was exactly the problem. Doh.
Now I am wondering why it *used* to work OK.
I bet, you upgraded you g++.
Best
Kai-Uwe Bux This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joh |
last post by:
hello,
i'm trying to understand how i could build following consecutive sets
from a root one using generator :
l =
would like to produce :
, , , ,
|
by: Rex_chaos |
last post by:
Hi all,
I am writing my own container and need an iterator. I am hesitating
if I should my iterator should inherited from std::iterator or just
write my own one. Please give me an idea.
BTW,...
|
by: Rex_chaos |
last post by:
Hi there,
I am learning template programming and there is a problem about
traits. Now consider a container and an iterator. Here is the code
// tag for const iterator and non-const iterator...
|
by: CoolPint |
last post by:
I am trying to write a generic heapsort (of course as a self-exercise)
with Iterator interface: something like blow....
But I got into trouble finding out the Iterator to the Child node. If...
|
by: Christian Christmann |
last post by:
Hi,
in the past I always appreciated your help and hope that you also can help
me this time. I've spent many many hours but still can't solve the
problem by myself and you are my last hope.
...
|
by: Steve R. Hastings |
last post by:
While studying iterators and generator expressions, I started wishing I
had some tools for processing the values. I wanted to be able to chain
together a set of functions, sort of like the...
|
by: nabh4u |
last post by:
hi,
i have a program where every thing is working properly. i have a vector with some values. i use iterators and delete a specific value in the vector. here the loop runs infinitely only for some...
|
by: ryanoasis |
last post by:
Working on a C++ assignment and I cant figure out the
problems I am having w/ Templates and Subclasses.
I know there are issues with templates and certain compilers
so I am not sure what the...
|
by: DJ Dharme |
last post by:
Hi,
I really like to use stl as much as possible in my code. But I
found it really hard to understand by looking into there source code.
I have no idea about what iterator traits, heaps and...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |