[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
:Function default parameter and name lookup??
From: |
Andreas Crauser |
Subject: |
:Function default parameter and name lookup?? |
Date: |
23 Nov 2004 02:54:00 -0800 |
Hi all,
when compiling the following code with g++-3.4.2, I get following
errors:
-----------CODE-------------------
template <class T>
class sseq {
public:
sseq()
{
test(T());
void (*test_func) (const T&) = test;
test_func(T());
}
};
class obj1 {
public:
void run() const {}
};
void test(const obj1& o) { o.run(); }
int main()
{
sseq<obj1> t1;
return 0;
}
------------ERRORS---------------
g++ -o template template.cpp
template.cpp: In constructor `sseq<T>::sseq()':
template.cpp:7: error: `test' undeclared (first use this function)
template.cpp:7: error: (Each undeclared identifier is reported only
once for each function it appears in.)
template.cpp: In function `void test(const obj1&)':
template.cpp:17: error: `void test(const obj1&)' used prior to
declaration
Obviously, the compiler performs an non-template dependent lookup for
function test at time of definition, when assigning
void (*test_func) (const T&) = test;
However, I would expect a template-dependent name lookup at time of
initialization. Has anyone any idea how to fix this problem?
Is this a bug or feature of the new name-lookup of g++-3.4?
Can I specify the assignment in any way so that the compiler performs
a lookup
for function test among the template versions?
Thanks for the help,
Andreas
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- :Function default parameter and name lookup??,
Andreas Crauser <=