Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2007-10-24 10:00:25


Peter Dimov wrote:
> Markus Schöpflin wrote:
>
>> Hmm, have a look at this:
>>
>> ---%<---
>> template <class T> struct foo {
>> void bar() { foobar(); }
>> };
>
> This call to foobar is not dependent on T. Try
>
> template <class T> struct foo
> {
> void bar( T * p ) { foobar( p ); }
> };

OK, what about this:

---%<---
template <class T> struct foo {
    T *p;
    void bar() { foobar(p); }
};

void foobar(int *p) {}

void argl() {
   foo<int> f;
   f.bar();
}
--->%---

I think this resembles the situation at hand now. I still get:

---%<---
"ComeauTest.c", line 3: error: identifier "foobar" is undefined
      void bar() { foobar(p); }
                   ^
           detected during instantiation of "void foo<T>::bar() [with T=int]"
                     at line 10
--->%---

And it works if you insert 'void foobar(int *p);' before struct foo.

Markus


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