With or without "using boo::work" in func.h, it doesn't pick the template
function in the namespace. However, changing "work(a)" to "work(10)" in func.h
compiles.
g++ error report:
func.h: In function void boo::rfunc(const boo::R<T>&) [with T = hpc::B]:
main.cpp:11: instantiated from here
func.h:14: error: call of overloaded work(const boo::R<hpc::B>&) is ambiguous
func.h:4: note: candidates are: void boo::work(T) [with T = boo::R<hpc::B>]
main.cpp:17: note: void hpc::work(T) [with T = boo::R<hpc::B>]
file func.h:
namespace boo {
template <typename T>
void work(T n) {
std::cout << "good bye work" << std::endl;
}
template <typename T>
class R { };
template <typename T>
void rfunc(const R<T>& a) {
using boo::work;
work(a);
}
} // namespace boo
File main.cpp:
#include <iostream>
#include "func.h"
using std::cout;
using std::endl;
namespace hpc {
class B { };
class A {
public:
void bfunc(void) { rfunc(n); }
protected:
boo::R<B> n;
};
template <typename T>
void work(T n) {
cout << "hello world work" << endl;
}
} // namespace hpc
using hpc::A;
int main(int argc, char* argv[])
{
A a;
a.bfunc();
return 0;
}
--
Summary: "using boo::work" does not resolve name resolution
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cshinyee at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31855