Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Template scope error

0 views
Skip to first unread message

Nicola Musatti

unread,
Oct 29, 2001, 10:45:17 AM10/29/01
to
Hallo,
while fiddling inside the Boost libraries I came across what I believe
to be a compiler bug. The following short program does not compile:

namespace A {
template <class T> struct foo {};
}

namespace B {
template <class T> int foo(const T& i) { return 0; }
}

int main(int, char* []) {
return 0;
}

I get the following error message:
[C++ Error] TemplInNamesp.cpp(10): E2479 Cannot have both a template
class and function named 'foo'

As the two templates are defined in different namespaces I believe the
above program is correct.

Cheers,
Nicola Musatti
Team Mongolian Wok

G.B.

unread,
Oct 29, 2001, 2:04:55 PM10/29/01
to
This is definitely a bug.
G.B.

"Nicola Musatti" <obje...@divalsim.it> wrote in message
news:3BDD798D...@divalsim.it...

Greg Chicares

unread,
Nov 6, 2001, 8:11:49 PM11/6/01
to
Nicola Musatti wrote:
>
> The following short program does not compile:
>
> namespace A {
> template <class T> struct foo {};
> }
>
> namespace B {
> template <class T> int foo(const T& i) { return 0; }
> }

If that were not legal, then what problem would namespaces solve?

Alan Bellingham

unread,
Nov 7, 2001, 5:37:13 AM11/7/01
to
Greg Chicares <chic...@mindspring.com> wrote:

But it is legal. It's just not legal _without_ the two declarations
being in different namespaces. The point about namespaces is that those
two declarations (quite possibly from two different 3rd party
libraries), should not interfere with each other.

Alan Bellingham
--
Team Mongolian Wok
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
<url:http://www.borland.com/newsgroups/netiquette.html> netiquette

Greg Chicares

unread,
Nov 8, 2001, 1:08:38 AM11/8/01
to
Alan Bellingham wrote:
>
> Greg Chicares <chic...@mindspring.com> wrote:
>
[snip Nicola's example with declarations in different namespaces]

> >
> >If that were not legal, then what problem would namespaces solve?
>
> But it is legal. It's just not legal _without_ the two declarations
> being in different namespaces. The point about namespaces is that those
> two declarations (quite possibly from two different 3rd party
> libraries), should not interfere with each other.

If that isn't what I said, then it's what I meant to say.

Alan Bellingham

unread,
Nov 8, 2001, 5:47:45 AM11/8/01
to
Greg Chicares <chic...@mindspring.com> wrote:

>If that isn't what I said, then it's what I meant to say.

Good. (It's just not how I read it.)

So, we're agreed? There's a bug?

Chris Uzdavinis (TeamB)

unread,
Nov 8, 2001, 7:18:41 AM11/8/01
to
Alan Bellingham <al...@episys.com> writes:

> Greg Chicares <chic...@mindspring.com> wrote:
>
> >If that isn't what I said, then it's what I meant to say.
>
> Good. (It's just not how I read it.)
>
> So, we're agreed? There's a bug?

I think so too. I've already reported it.

--
Chris(TeamB);

Greg Chicares

unread,
Nov 10, 2001, 12:13:05 AM11/10/01
to
Alan Bellingham wrote:
>
> So, we're agreed? There's a bug?

We're agreed. There's a bug.

0 new messages