Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #15175

problem with template friend partial specialization

From Andrey Dj <djdron@gmail.com>
Newsgroups comp.lang.c++
Subject problem with template friend partial specialization
Date 2012-04-02 02:35 -0700
Organization http://groups.google.com
Message-ID <13976142.1067.1333359344646.JavaMail.geo-discussion-forums@ynel5> (permalink)

Show all headers | View raw


Hello!

I found some interesting case of non-compiling C++ code.
Look at first example:

--------------------------------
template<class T> void Foo(T*);
class Bar;
template<> void Foo(Bar*);

class Bar
{
    friend void ::Foo<>(Bar*);
};
--------------------------------

Compiling... All fine.

Now add to Foo return type of Baz:

--------------------------------
class Baz {};

template<class T> Baz Foo(T*);
class Bar;
template<> Baz Foo(Bar*);

class Bar
{
    friend Baz ::Foo<>(Bar*);
};
--------------------------------

Trying to compile:
MSVC: error C2039: 'Foo' : is not a member of 'Baz'
GCC: error: 'Foo' in class 'Baz' does not name a type

Is there any way to declare such friend partial specialization?

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

problem with template friend partial specialization Andrey Dj <djdron@gmail.com> - 2012-04-02 02:35 -0700
  Re: problem with template friend partial specialization Victor Bazarov <v.bazarov@comcast.invalid> - 2012-04-03 08:52 -0400
    Re: problem with template friend partial specialization Kalle Olavi Niemitalo <kon@iki.fi> - 2012-04-04 01:15 +0300
      Re: problem with template friend partial specialization Andrey Dj <djdron@gmail.com> - 2012-04-05 07:09 -0700

csiph-web