This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
g++ doesn't find the right ctor
- From: Matthias Kretz <Matthias dot Kretz at kip dot uni-heidelberg dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 11 Sep 2009 18:10:07 +0200
- Subject: g++ doesn't find the right ctor
Hi,
the following code does not compile:
struct A
{
template<typename T> A(const T *, const float *T::*) {}
};
struct B
{
float *f;
};
int main()
{
B x;
A y(&x, &B::f);
return 0;
}
Output is:
g++ -Wall -O3 -Wextra main.cpp -o test
main.cpp: In function âint main()â:
main.cpp:14: error: no matching function for call to âA::A(B*, float* B::*)â
main.cpp:2: note: candidates are: A::A(const A&)
It compiles if I change B to
struct B
{
const float *f;
};
or the A ctor to
template<typename T> A(const T *, float *T::*) {}
I believe g++ is at fault here. Or am I expecting too much?
Regards,
Matthias