public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* egcs 1.1.1: odd warning message with template friend functions
@ 1999-03-15  6:19 Jonathan Pryor
       [not found] ` < 11ad01be6eee$c7a47bf0$e63d2509@jonpryor.raleigh.ibm.com >
  1999-03-31 19:45 ` Jonathan Pryor
  0 siblings, 2 replies; 10+ messages in thread
From: Jonathan Pryor @ 1999-03-15  6:19 UTC (permalink / raw)
  To: Cygwin Mailing List

Note: I'm not complaining about the resulting executable; I'm
complaining about the warning message itself.

When I compile the attached source code, I get the 
following warning:

    mi.cpp:7: warning: friend declaration `bool operator ==(
        const class meta_info<T> &, const class meta_info<T> &)'
    mi.cpp:7: warning:   declares a non-template function
    mi.cpp:7: warning:   (if this is not what you intended, make sure
    mi.cpp:7: warning:   the function template has already been declared,
    mi.cpp:7: warning:   and add <> after the function name here)
    mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
        const T &)'
    mi.cpp:8: warning:   declares a non-template function

The final executable runs fine; it's just that this message doesn't 
make sense to me.  The line that causes the warning is the following:

    template <typename T>
    class meta_info {
        friend bool operator== ( const meta_info<T>&, 
            const meta_info<T>& );
        /* ... */
    };

Since the friend declaration is in a template class, I fail
to see how `operator==' could *not* be a template function,
which the warning message suggests.

Furthermore, in Stroustrup, 3rd Edition (pages 854-855), he
has a similar example (a template class with a friend declaration),
and states that because the friend declaration was in a template
class, the friend must also be a template.  In this example,
the friend declaration did *not* have `<>' appended to the function
name.

If I follow the compilers suggestion and modify the class
declaration to:

    template <typename T>
    class meta_info {
        // note `<>' after `operator=='
        friend bool operator==<> ( const meta_info<T>&, 
            const meta_info<T>& );
        /* ... */
    };

egcs will compile this without any error messages, but now
MSVC6 has caniptions...  In addition, it seems to go against
what was stated in Stroustrup, so I'm finding this...bizarre.

(Yes, we could argue that it's a bug in MSVC -- except that
Stroutstrup doesn't mention needing to add a `<>' to make
the friend a template.  In addition, MSVC compiles the original
version without any errors/warnings -- so (to me) it doesn't 
make sense to call it an MSVC bug.)

Again, this doesn't seem to cause any problems in the executable.
I just don't like warning messages that seem to be incorrect, or,
at the very least, don't make any sense for this circumstance.

In a related question: Should I to send future compiler bug 
reports to the cygwin mailing list, to the egcs-bugs mailing
list, or to both?  I didn't see any reference to this on the
web site, so I'm just "playing this by ear"...

Thanks,
 - Jon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
       [not found] ` < 11ad01be6eee$c7a47bf0$e63d2509@jonpryor.raleigh.ibm.com >
@ 1999-03-15  8:40   ` Mumit Khan
  1999-03-31 19:45     ` Mumit Khan
  1999-03-15  8:46   ` Bob Aglietti
  1 sibling, 1 reply; 10+ messages in thread
From: Mumit Khan @ 1999-03-15  8:40 UTC (permalink / raw)
  To: Jonathan Pryor; +Cc: Cygwin Mailing List

"Jonathan Pryor" <jonpryor@vt.edu> writes:
> ------=_NextPart_000_11AA_01BE6EC4.CC9E62D0
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: 7bit
> 
> Note: I'm not complaining about the resulting executable; I'm
> complaining about the warning message itself.
> 
> When I compile the attached source code, I get the 
> following warning:
> 
>     mi.cpp:7: warning: friend declaration `bool operator ==(
>         const class meta_info<T> &, const class meta_info<T> &)'
>     mi.cpp:7: warning:   declares a non-template function
>     mi.cpp:7: warning:   (if this is not what you intended, make sure
>     mi.cpp:7: warning:   the function template has already been declared,
>     mi.cpp:7: warning:   and add <> after the function name here)
>     mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
>         const T &)'
>     mi.cpp:8: warning:   declares a non-template function

Please see "Guiding Declarations" in the standard. EGCS is correct; MSVC
doesn't implmenent this correctly. This was added after Stroustrup book
came out (at least my copy of it).

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
       [not found] ` < 11ad01be6eee$c7a47bf0$e63d2509@jonpryor.raleigh.ibm.com >
  1999-03-15  8:40   ` Mumit Khan
@ 1999-03-15  8:46   ` Bob Aglietti
       [not found]     ` < 199903151648.AA251596512@hplagl.hpl.hp.com >
  1999-03-31 19:45     ` Bob Aglietti
  1 sibling, 2 replies; 10+ messages in thread
From: Bob Aglietti @ 1999-03-15  8:46 UTC (permalink / raw)
  To: jonpryor; +Cc: cygwin

 >
 >When I compile the attached source code, I get the 
 >following warning:
 >
 >    mi.cpp:7: warning: friend declaration `bool operator ==(
 >        const class meta_info<T> &, const class meta_info<T> &)'
 >    mi.cpp:7: warning:   declares a non-template function
 >    mi.cpp:7: warning:   (if this is not what you intended, make sure
 >    mi.cpp:7: warning:   the function template has already been declared,
 >    mi.cpp:7: warning:   and add <> after the function name here)
 >    mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
 >        const T &)'
 >    mi.cpp:8: warning:   declares a non-template function

Jonathan,

I don't know why this message shows up in the current version, but I installed
the 2.8.1 compiler on one of my unix systems and it's nice enough to mention
that I might want to use the option: '-fguiding-decls'.  Sure enough, no
warnings.  This also works with the egcs-2.91.57 compiler I'm using on my pc.

I still don't understand what changed but this'll at least get around it.

	-Bob


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
       [not found]     ` < 199903151648.AA251596512@hplagl.hpl.hp.com >
@ 1999-03-15  9:17       ` Mumit Khan
  1999-03-31 19:45         ` Mumit Khan
  0 siblings, 1 reply; 10+ messages in thread
From: Mumit Khan @ 1999-03-15  9:17 UTC (permalink / raw)
  To: Bob Aglietti; +Cc: jonpryor, cygwin

Bob Aglietti <grut@hplagl.hpl.hp.com> writes:
> 
> I don't know why this message shows up in the current version, but I installe
> d
> the 2.8.1 compiler on one of my unix systems and it's nice enough to mention
> that I might want to use the option: '-fguiding-decls'.  Sure enough, no
> warnings.  This also works with the egcs-2.91.57 compiler I'm using on my pc.
> 
> I still don't understand what changed but this'll at least get around it.
> 

I strongly recommend against using the -fguiding-decl switch. Fixing your
code (and ifdef'ing for non-conformant compilers) is the right way to go. 
This particular option can cause you much grief when you're using iostreams
and other C++ libraries that were not built with this option as well.

Also, comparison to gcc-2.8.1 is usually not a good idea. The C++ front in
FSF GCC is so old and buggy that it's almost unusable for any real code
that makes heavy use of templates, exceptions, etc.

I'm not going to bore the non-C++ users with an explanation of guiding
declarations; the ANSI/ISO standard describes it well, and so do lots of
postings to C++ specific forums ( http://www.dejanews.com/ is your friend).

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* egcs 1.1.1: odd warning message with template friend functions
  1999-03-15  6:19 egcs 1.1.1: odd warning message with template friend functions Jonathan Pryor
       [not found] ` < 11ad01be6eee$c7a47bf0$e63d2509@jonpryor.raleigh.ibm.com >
@ 1999-03-31 19:45 ` Jonathan Pryor
  1 sibling, 0 replies; 10+ messages in thread
From: Jonathan Pryor @ 1999-03-31 19:45 UTC (permalink / raw)
  To: Cygwin Mailing List

[-- Attachment #1: Type: text/plain, Size: 2701 bytes --]

Note: I'm not complaining about the resulting executable; I'm
complaining about the warning message itself.

When I compile the attached source code, I get the 
following warning:

    mi.cpp:7: warning: friend declaration `bool operator ==(
        const class meta_info<T> &, const class meta_info<T> &)'
    mi.cpp:7: warning:   declares a non-template function
    mi.cpp:7: warning:   (if this is not what you intended, make sure
    mi.cpp:7: warning:   the function template has already been declared,
    mi.cpp:7: warning:   and add <> after the function name here)
    mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
        const T &)'
    mi.cpp:8: warning:   declares a non-template function

The final executable runs fine; it's just that this message doesn't 
make sense to me.  The line that causes the warning is the following:

    template <typename T>
    class meta_info {
        friend bool operator== ( const meta_info<T>&, 
            const meta_info<T>& );
        /* ... */
    };

Since the friend declaration is in a template class, I fail
to see how `operator==' could *not* be a template function,
which the warning message suggests.

Furthermore, in Stroustrup, 3rd Edition (pages 854-855), he
has a similar example (a template class with a friend declaration),
and states that because the friend declaration was in a template
class, the friend must also be a template.  In this example,
the friend declaration did *not* have `<>' appended to the function
name.

If I follow the compilers suggestion and modify the class
declaration to:

    template <typename T>
    class meta_info {
        // note `<>' after `operator=='
        friend bool operator==<> ( const meta_info<T>&, 
            const meta_info<T>& );
        /* ... */
    };

egcs will compile this without any error messages, but now
MSVC6 has caniptions...  In addition, it seems to go against
what was stated in Stroustrup, so I'm finding this...bizarre.

(Yes, we could argue that it's a bug in MSVC -- except that
Stroutstrup doesn't mention needing to add a `<>' to make
the friend a template.  In addition, MSVC compiles the original
version without any errors/warnings -- so (to me) it doesn't 
make sense to call it an MSVC bug.)

Again, this doesn't seem to cause any problems in the executable.
I just don't like warning messages that seem to be incorrect, or,
at the very least, don't make any sense for this circumstance.

In a related question: Should I to send future compiler bug 
reports to the cygwin mailing list, to the egcs-bugs mailing
list, or to both?  I didn't see any reference to this on the
web site, so I'm just "playing this by ear"...

Thanks,
 - Jon

[-- Attachment #2: mi.cpp --]
[-- Type: text/x-c++, Size: 987 bytes --]

// Odd egcs behavior with template-friend functions.

#include <stdio.h>

template <typename T>
class meta_info {
  friend bool operator==<> ( const meta_info<T>&, const meta_info<T>& );
  friend meta_info<T> metaid<> ( const T& );

  meta_info<T>& operator=(const meta_info<T>& );  // no assignment.
  meta_info ( const meta_info<T>& );              // no cpy ctor
  meta_info() {}                                  // only friends can create 
                                                  //  the class.
public:

};

template <typename T>
bool operator== ( const meta_info<T>&, const meta_info<T>& ) {
  return false;
}

template <typename T>
inline meta_info<T> metaid ( const T& ) {
  meta_info<T> mi;
  return mi;
}

class meta_info<int> {
public:
  static long max () throw() {
    return 42;
    // should be: return std::numeric_limits<int>::max();
  }
};


int main (int, char **) {
  int n = 5;
  printf ("meta_info<int>::max() is: %i\n", metaid(n).max() );
  return 0;
}



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
  1999-03-15  8:46   ` Bob Aglietti
       [not found]     ` < 199903151648.AA251596512@hplagl.hpl.hp.com >
@ 1999-03-31 19:45     ` Bob Aglietti
  1 sibling, 0 replies; 10+ messages in thread
From: Bob Aglietti @ 1999-03-31 19:45 UTC (permalink / raw)
  To: jonpryor; +Cc: cygwin

 >
 >When I compile the attached source code, I get the 
 >following warning:
 >
 >    mi.cpp:7: warning: friend declaration `bool operator ==(
 >        const class meta_info<T> &, const class meta_info<T> &)'
 >    mi.cpp:7: warning:   declares a non-template function
 >    mi.cpp:7: warning:   (if this is not what you intended, make sure
 >    mi.cpp:7: warning:   the function template has already been declared,
 >    mi.cpp:7: warning:   and add <> after the function name here)
 >    mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
 >        const T &)'
 >    mi.cpp:8: warning:   declares a non-template function

Jonathan,

I don't know why this message shows up in the current version, but I installed
the 2.8.1 compiler on one of my unix systems and it's nice enough to mention
that I might want to use the option: '-fguiding-decls'.  Sure enough, no
warnings.  This also works with the egcs-2.91.57 compiler I'm using on my pc.

I still don't understand what changed but this'll at least get around it.

	-Bob


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
  1999-03-15  9:17       ` Mumit Khan
@ 1999-03-31 19:45         ` Mumit Khan
  0 siblings, 0 replies; 10+ messages in thread
From: Mumit Khan @ 1999-03-31 19:45 UTC (permalink / raw)
  To: Bob Aglietti; +Cc: jonpryor, cygwin

Bob Aglietti <grut@hplagl.hpl.hp.com> writes:
> 
> I don't know why this message shows up in the current version, but I installe
> d
> the 2.8.1 compiler on one of my unix systems and it's nice enough to mention
> that I might want to use the option: '-fguiding-decls'.  Sure enough, no
> warnings.  This also works with the egcs-2.91.57 compiler I'm using on my pc.
> 
> I still don't understand what changed but this'll at least get around it.
> 

I strongly recommend against using the -fguiding-decl switch. Fixing your
code (and ifdef'ing for non-conformant compilers) is the right way to go. 
This particular option can cause you much grief when you're using iostreams
and other C++ libraries that were not built with this option as well.

Also, comparison to gcc-2.8.1 is usually not a good idea. The C++ front in
FSF GCC is so old and buggy that it's almost unusable for any real code
that makes heavy use of templates, exceptions, etc.

I'm not going to bore the non-C++ users with an explanation of guiding
declarations; the ANSI/ISO standard describes it well, and so do lots of
postings to C++ specific forums ( http://www.dejanews.com/ is your friend).

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
  1999-03-15  8:40   ` Mumit Khan
@ 1999-03-31 19:45     ` Mumit Khan
  0 siblings, 0 replies; 10+ messages in thread
From: Mumit Khan @ 1999-03-31 19:45 UTC (permalink / raw)
  To: Jonathan Pryor; +Cc: Cygwin Mailing List

"Jonathan Pryor" <jonpryor@vt.edu> writes:
> ------=_NextPart_000_11AA_01BE6EC4.CC9E62D0
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: 7bit
> 
> Note: I'm not complaining about the resulting executable; I'm
> complaining about the warning message itself.
> 
> When I compile the attached source code, I get the 
> following warning:
> 
>     mi.cpp:7: warning: friend declaration `bool operator ==(
>         const class meta_info<T> &, const class meta_info<T> &)'
>     mi.cpp:7: warning:   declares a non-template function
>     mi.cpp:7: warning:   (if this is not what you intended, make sure
>     mi.cpp:7: warning:   the function template has already been declared,
>     mi.cpp:7: warning:   and add <> after the function name here)
>     mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
>         const T &)'
>     mi.cpp:8: warning:   declares a non-template function

Please see "Guiding Declarations" in the standard. EGCS is correct; MSVC
doesn't implmenent this correctly. This was added after Stroustrup book
came out (at least my copy of it).

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
  1999-03-15 10:46 Jonathan Pryor
@ 1999-03-31 19:45 ` Jonathan Pryor
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Pryor @ 1999-03-31 19:45 UTC (permalink / raw)
  To: Jonathan Pryor, Mumit Khan; +Cc: Cygwin Mailing List

Mumit Khan <khan@xraylith.wisc.EDU> writes:

>"Jonathan Pryor" <jonpryor@vt.edu> writes:
>> ------=_NextPart_000_11AA_01BE6EC4.CC9E62D0
>> Content-Type: text/plain;
>> charset="iso-8859-1"
>> Content-Transfer-Encoding: 7bit
>>
>> Note: I'm not complaining about the resulting executable; I'm
>> complaining about the warning message itself.
>>
>> When I compile the attached source code, I get the
>> following warning:
>>
>>     mi.cpp:7: warning: friend declaration `bool operator ==(
>>         const class meta_info<T> &, const class meta_info<T> &)'
>>     mi.cpp:7: warning:   declares a non-template function
>>     mi.cpp:7: warning:   (if this is not what you intended, make sure
>>     mi.cpp:7: warning:   the function template has already been declared,
>>     mi.cpp:7: warning:   and add <> after the function name here)
>>     mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
>>         const T &)'
>>     mi.cpp:8: warning:   declares a non-template function
>
>Please see "Guiding Declarations" in the standard. EGCS is correct; MSVC
>doesn't implmenent this correctly. This was added after Stroustrup book
>came out (at least my copy of it).
>
>Regards,
>Mumit

If it was added after Stroustrup, that would cure some of my
confusion...  But I'm always confused.  ;-)  So....

(In reference to a later note you sent to Bob Aglietti:)
Please, bore me with guiding declarations!  :-)

As for Dejanews -- I tried searching for "guiding declarations"
and "guiding decl", but didn't find too much that helped.

In all seriousness, I'm currently looking at the draft C++ standard
available at http://www.cygnus.com/iso/ .  Hopefully this is current
enough... (though with my luck, it's incorrect and the only way
to know for sure is to spend the $18 (?) to get a real copy of
the standard -- which might not be a bad idea, actually...)

However, I tried searching for "Guiding Declarations", and didn't
find anything.  What I did find was section 14.5.3 -- Friends --
and a lot of confusion.

Assuming I'm reading this correctly (always a good question), then
in the following template class:

    // prototypes
    template<class T> class task;
    template<class T> task<T>* preempt(task<T>*);

    template<class T> class task {
     //  ...
     friend void next_time();
       // all task specializations have the non-template function
       // next_time() as a friend.

     friend void process(task<T>*);
       // "each specialization of the task class template has an
       // appropriately typed function process as a friend, and
       // this friend is not a function template specialization"
       //
       // OK, it's not a specialization; but is it still a template?
       // I think this declaration matches my original report.

     friend task<T>* preempt<T>(task<T>*);
       // "each specialization of the task class template has the
       // appropriate specialization of the function template
       // preempt as a friend"
       //
       // This would match the syntax egcs was looking for.

     template<class C> friend int func(C);
       // "each specialization of the task class template has all
       // specializations of the function template func as friends".
       //
       // Oddly enough, this actually compiles find with both
       // egcs and MSVC...

     //  ...
    };

The 2nd friend declaration resembles what I was curious about.
But the standard doesn't seem to specify whether or not the function
must be a template; "an appropriately typed function" sounds like
a template, but I'd just like to verify this.

If "an appropriately typed function" is in fact a template, then
I shouldn't be getting a warning for the following

    template <typename T>
    class meta_info {
      friend const meta_info<T>& metaid ( const T& );
      meta_info ();
    public:
    };

    template <typename T>
    const meta_info<T>& metaid ( const T& ) {
      meta_info<T> mi;
      return mi;
    }

So what's the scoop here?  What's "an appropriately typed function"?
Does it mean it'll look for a non-template function with the same
types at compile time?  If a non-template function with the correct
types isn't found, but a template function with the same prototype
exists, will a standard-conforming compiler use that?

If the last question is true, then why (again) give a warning about
declaring a non-template function?  Is it "safe" to ignore this
warning in this case, then?

Thanks,
 - Jon


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: egcs 1.1.1: odd warning message with template friend functions
@ 1999-03-15 10:46 Jonathan Pryor
  1999-03-31 19:45 ` Jonathan Pryor
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Pryor @ 1999-03-15 10:46 UTC (permalink / raw)
  To: Jonathan Pryor, Mumit Khan; +Cc: Cygwin Mailing List

Mumit Khan <khan@xraylith.wisc.EDU> writes:

>"Jonathan Pryor" <jonpryor@vt.edu> writes:
>> ------=_NextPart_000_11AA_01BE6EC4.CC9E62D0
>> Content-Type: text/plain;
>> charset="iso-8859-1"
>> Content-Transfer-Encoding: 7bit
>>
>> Note: I'm not complaining about the resulting executable; I'm
>> complaining about the warning message itself.
>>
>> When I compile the attached source code, I get the
>> following warning:
>>
>>     mi.cpp:7: warning: friend declaration `bool operator ==(
>>         const class meta_info<T> &, const class meta_info<T> &)'
>>     mi.cpp:7: warning:   declares a non-template function
>>     mi.cpp:7: warning:   (if this is not what you intended, make sure
>>     mi.cpp:7: warning:   the function template has already been declared,
>>     mi.cpp:7: warning:   and add <> after the function name here)
>>     mi.cpp:8: warning: friend declaration `class meta_info<T> metaid(
>>         const T &)'
>>     mi.cpp:8: warning:   declares a non-template function
>
>Please see "Guiding Declarations" in the standard. EGCS is correct; MSVC
>doesn't implmenent this correctly. This was added after Stroustrup book
>came out (at least my copy of it).
>
>Regards,
>Mumit

If it was added after Stroustrup, that would cure some of my
confusion...  But I'm always confused.  ;-)  So....

(In reference to a later note you sent to Bob Aglietti:)
Please, bore me with guiding declarations!  :-)

As for Dejanews -- I tried searching for "guiding declarations"
and "guiding decl", but didn't find too much that helped.

In all seriousness, I'm currently looking at the draft C++ standard
available at http://www.cygnus.com/iso/ .  Hopefully this is current
enough... (though with my luck, it's incorrect and the only way
to know for sure is to spend the $18 (?) to get a real copy of
the standard -- which might not be a bad idea, actually...)

However, I tried searching for "Guiding Declarations", and didn't
find anything.  What I did find was section 14.5.3 -- Friends --
and a lot of confusion.

Assuming I'm reading this correctly (always a good question), then
in the following template class:

    // prototypes
    template<class T> class task;
    template<class T> task<T>* preempt(task<T>*);

    template<class T> class task {
     //  ...
     friend void next_time();
       // all task specializations have the non-template function
       // next_time() as a friend.

     friend void process(task<T>*);
       // "each specialization of the task class template has an
       // appropriately typed function process as a friend, and
       // this friend is not a function template specialization"
       //
       // OK, it's not a specialization; but is it still a template?
       // I think this declaration matches my original report.

     friend task<T>* preempt<T>(task<T>*);
       // "each specialization of the task class template has the
       // appropriate specialization of the function template
       // preempt as a friend"
       //
       // This would match the syntax egcs was looking for.

     template<class C> friend int func(C);
       // "each specialization of the task class template has all
       // specializations of the function template func as friends".
       //
       // Oddly enough, this actually compiles find with both
       // egcs and MSVC...

     //  ...
    };

The 2nd friend declaration resembles what I was curious about.
But the standard doesn't seem to specify whether or not the function
must be a template; "an appropriately typed function" sounds like
a template, but I'd just like to verify this.

If "an appropriately typed function" is in fact a template, then
I shouldn't be getting a warning for the following

    template <typename T>
    class meta_info {
      friend const meta_info<T>& metaid ( const T& );
      meta_info ();
    public:
    };

    template <typename T>
    const meta_info<T>& metaid ( const T& ) {
      meta_info<T> mi;
      return mi;
    }

So what's the scoop here?  What's "an appropriately typed function"?
Does it mean it'll look for a non-template function with the same
types at compile time?  If a non-template function with the correct
types isn't found, but a template function with the same prototype
exists, will a standard-conforming compiler use that?

If the last question is true, then why (again) give a warning about
declaring a non-template function?  Is it "safe" to ignore this
warning in this case, then?

Thanks,
 - Jon


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1999-03-31 19:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-15  6:19 egcs 1.1.1: odd warning message with template friend functions Jonathan Pryor
     [not found] ` < 11ad01be6eee$c7a47bf0$e63d2509@jonpryor.raleigh.ibm.com >
1999-03-15  8:40   ` Mumit Khan
1999-03-31 19:45     ` Mumit Khan
1999-03-15  8:46   ` Bob Aglietti
     [not found]     ` < 199903151648.AA251596512@hplagl.hpl.hp.com >
1999-03-15  9:17       ` Mumit Khan
1999-03-31 19:45         ` Mumit Khan
1999-03-31 19:45     ` Bob Aglietti
1999-03-31 19:45 ` Jonathan Pryor
1999-03-15 10:46 Jonathan Pryor
1999-03-31 19:45 ` Jonathan Pryor

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).