Struggling with template classes

J

Jaco Naude

Hi

I've run into a problem with template classes and mingw32 compiler
gives me the following:

source\EnvironmentManager.cpp: In constructor
`EnvironmentManager::EnvironmentManager()':
source\EnvironmentManager.cpp:60: error: no matching function for call
to `AttachmentDiscoverer<IData*>::setAttachmentManager
(AttachmentManager<IData*>*)'
.../../include/QtSF/AttachmentDiscoverer.h:23: note: candidates are:
void AttachmentDiscoverer<T>::setAttachmentManager
(AttachmentManager<T*>&) [with T = IData*]

But the candidate is exactly what I called... How can this be?
If it would help to post the classes please let me know.

Thanks in advance,
Jaco
 
A

anon

Jaco said:
Hi

I've run into a problem with template classes and mingw32 compiler
gives me the following:

source\EnvironmentManager.cpp: In constructor
`EnvironmentManager::EnvironmentManager()':
source\EnvironmentManager.cpp:60: error: no matching function for call
to `AttachmentDiscoverer<IData*>::setAttachmentManager
(AttachmentManager<IData*>*)'
../../include/QtSF/AttachmentDiscoverer.h:23: note: candidates are:
void AttachmentDiscoverer<T>::setAttachmentManager
(AttachmentManager<T*>&) [with T = IData*]

But the candidate is exactly what I called... How can this be?
If it would help to post the classes please let me know.


Pick one and read:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
http://www.catb.org/~esr/faqs/smart-questions.html#code
http://www.google.de/search?hl=en&q=how+to+ask+smart+questions&btnG=Google+Search
 
D

DerTopper

Hi

I've run into a problem with template classes and mingw32 compiler
gives me the following:

source\EnvironmentManager.cpp: In constructor
`EnvironmentManager::EnvironmentManager()':
source\EnvironmentManager.cpp:60: error: no matching function for call
to `AttachmentDiscoverer<IData*>::setAttachmentManager
(AttachmentManager<IData*>*)'
../../include/QtSF/AttachmentDiscoverer.h:23: note: candidates are:
void AttachmentDiscoverer<T>::setAttachmentManager
(AttachmentManager<T*>&) [with T = IData*]

But the candidate is exactly what I called... How can this be?
If it would help to post the classes please let me know.

It would help if you posted a minimal compilable, and above all,
standard-conformant example that exposes the problem you experience.
In most cases, stripping down your code to get such an example will
give you enough clues about what went wrong with your code. In case
you find the answer for yourself and find it interesting, don't
hestitate to post your solution here.

Regards,
Stuart
 
S

SG

Jaco said:
source\EnvironmentManager.cpp:60: error: no matching function for call
to `AttachmentDiscoverer<IData*>::setAttachmentManager
(AttachmentManager<IData*>*)'
../../include/QtSF/AttachmentDiscoverer.h:23: note: candidates are:
void AttachmentDiscoverer<T>::setAttachmentManager
(AttachmentManager<T*>&) [with T = IData*]

But the candidate is exactly what I called...

Are you sure?

call: setAttachmentManager(AttachmentManager<IData*>*)
candidate: setAttachmentManager(AttachmentManager<IData**>&)

Cheers!
SG
 
A

Alan Woodland

Jaco said:
Hi

I've run into a problem with template classes and mingw32 compiler
gives me the following:

source\EnvironmentManager.cpp: In constructor
`EnvironmentManager::EnvironmentManager()':
source\EnvironmentManager.cpp:60: error: no matching function for call
to `AttachmentDiscoverer<IData*>::setAttachmentManager
(AttachmentManager<IData*>*)'
../../include/QtSF/AttachmentDiscoverer.h:23: note: candidates are:
void AttachmentDiscoverer<T>::setAttachmentManager
(AttachmentManager<T*>&) [with T = IData*]

But the candidate is exactly what I called... How can this be?
If it would help to post the classes please let me know.
The clue is in the error message! You tried to pass an
AttachmentManager<IData*>* to a template function that apparently the
closest possible match takes a reference to an
AttachmentManager<IData**> (substitute the T = IData* into the candidate
message). Note the position of the second * in both cases.

Alan
 
J

Jaco Naude

Jaco said:
I've run into a problem with template classes and mingw32 compiler
gives me the following:
source\EnvironmentManager.cpp: In constructor
`EnvironmentManager::EnvironmentManager()':
source\EnvironmentManager.cpp:60: error: no matching function for call
to `AttachmentDiscoverer<IData*>::setAttachmentManager
(AttachmentManager<IData*>*)'
../../include/QtSF/AttachmentDiscoverer.h:23: note: candidates are:
void AttachmentDiscoverer<T>::setAttachmentManager
(AttachmentManager<T*>&) [with T = IData*]
But the candidate is exactly what I called... How can this be?
If it would help to post the classes please let me know.

The clue is in the error message! You tried to pass an
AttachmentManager<IData*>* to a template function that apparently the
closest possible match takes a reference to an
AttachmentManager<IData**> (substitute the T = IData* into the candidate
message). Note the position of the second * in both cases.

Alan

Thank you for all the constructive replies. It was my mistake, I've
not used really used template classes before and should have picked it
up.



Thanks for your time.
 
K

KamYach

Jaco Naude wrote:

[...]
Thank you for all the constructive replies. It was my mistake, I've
not used really used template classes before and should have picked it
up.

Since you're just starting, learn the correct name: "class template" (also
"function template"). The meaning is that this is a template for a class
(or function). Putting the word "template" first is as erroneous as a
template for a website a "template website" (though that would be an
appropriate name for a website that contains templates). Putting it first
implies that it's a class or function, which it is not; it's a TEMPLATE
that can GENERATE a class or function, given types/values to instantiate
with.</rant>

If you know it well, are you guilty if you still make the same
mistake ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top