public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31855] New: "using boo::work" does not resolve name resolution
@ 2007-05-07 13:19 cshinyee at gmail dot com
2007-05-09 15:35 ` [Bug c++/31855] " bangerth at dealii dot org
0 siblings, 1 reply; 2+ messages in thread
From: cshinyee at gmail dot com @ 2007-05-07 13:19 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/31855] "using boo::work" does not resolve name resolution
2007-05-07 13:19 [Bug c++/31855] New: "using boo::work" does not resolve name resolution cshinyee at gmail dot com
@ 2007-05-09 15:35 ` bangerth at dealii dot org
0 siblings, 0 replies; 2+ messages in thread
From: bangerth at dealii dot org @ 2007-05-09 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bangerth at dealii dot org 2007-05-09 16:34 -------
The code originally given is indeed ambiguous. It boils down to this:
-------------------
namespace boo {
template <typename T> void work(T n);
template <typename T> struct R { };
template <typename T>
void rfunc(const R<T>& a) {
using boo::work;
work(a);
}
}
namespace hpc {
template <typename T> void work(T n);
struct B { };
boo::R<B> n;
void bfunc(void) { rfunc(n); }
}
-----------------
In boo:rfunc, we call work(a). Because 'a' is template dependent, we search
the current as well as all namespaces associated with the template arguments.
This includes namespace hpc.
As for the question why the qualified version "work<R<T> >(a)" works fine --
this is subject of one of the Defect Reports dealing with the question whether
argument dependent lookup also applies to functions with specified template
parameter lists.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31855
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-09 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-07 13:19 [Bug c++/31855] New: "using boo::work" does not resolve name resolution cshinyee at gmail dot com
2007-05-09 15:35 ` [Bug c++/31855] " bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).