Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2004-08-31 04:19:59


Hello,

attached is a patch which makes the format tests compile on tru64cxx65. It
turns out that the compiler has troubles with the following code snippet:

---%<---
template <class X> class foo;

namespace detail {
template<class X>
void bar (foo<X>& self);
}

template<class X>
class foo
{
public:
   template<class Y>
   friend void detail::bar(foo<Y>&);
};
--->%---

This gives the following error message:

cxx: Error: /usr/users/schoepf/net/tmp/test_namelookup.cpp, line 13:
           declaration is incompatible with function template
           "void detail::bar(foo<X> &)" (declared at line 5)
   friend void detail::bar(foo<Y>&);
----------------------^

There are several possible workarounds I found, namely moving bar() out of
the detail namespace, or making bar() a simple member of foo (not a member
template), or just removing the friend declaration alltogether.

I decided to use the latter workaround as it is already present in the
format library for other compilers.

Markus

Index: format_class.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/format/format_class.hpp,v
retrieving revision 1.21
diff -u -r1.21 format_class.hpp
--- format_class.hpp 1 Feb 2004 14:57:09 -0000 1.21
+++ format_class.hpp 31 Aug 2004 09:11:02 -0000
@@ -83,7 +83,8 @@
 
 #if !defined( BOOST_NO_MEMBER_TEMPLATE_FRIENDS ) \
     && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570) \
- && !BOOST_WORKAROUND( _CRAYC, != 0)
+ && !BOOST_WORKAROUND( _CRAYC, != 0) \
+ && !BOOST_WORKAROUND(__DECCXX_VER, <= 60590041)
         // use friend templates and private members only if supported
 
 #ifndef BOOST_NO_TEMPLATE_STD_STREAM


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk