This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]