Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2004-02-22 07:52:11


"John Maddock" <john_at_[hidden]> wrote

> > I believe config macro BOOST_NO_MEMBER_TEMPLATE_FRIENDS should be
defined
> > for BCB 6.
> >

> > - compiling test file boost_no_mem_templ_frnds.cxx fails,
>
> Works for me, both with bcb5 and bcb6.
>
Oops, my mistake. Nevertheless I bellow is code snippet which fails
on BCB 6 (and VC6) and compiles on Intel C++ 7 and Comeau online:

------------------------
template <class T>
class foo;

template <class T>
bool must_be_friend_proc(const foo<T>& f);

template <class T>
class foo
{
private:
   template<typename Y> friend bool must_be_friend_proc(const foo<Y>& f);
   int i;
public:
   foo(){ i = 0; }

   void call_friend() {
        must_be_friend_proc<T>(*this);
   }
};

template <class T>
bool must_be_friend_proc(const foo<T>& f)
{ return f.i != 0; }

int main(int argc, char* argv[])
{
   foo<int> fi;
   fi.call_friend();
   return 0;
}
------------------------

The difference to file boost_no_mem_templ_frnds.cxx is
that I actually call friend.

/Pavel


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