www.digitalmars.com         C & C++   DMDScript  

c++ - template bug

reply Christof Meerwald <cmeerw web.de> writes:
template <class T>
struct N
{ };

template <class T>
struct L
{
  ~L()
  {
    int i = sizeof(N<T>);
  }
};

template <typename T> inline void checked_delete(T * x)
{
  typedef char type_must_be_complete[sizeof(T)];
  delete x;
}

template<typename T>
struct S
{
 public:
  template<typename Y> void f(Y y)
  {
    checked_delete<T>((T *) 0);
  }
};


struct A
{
  void f();
  void g();
};

inline void A::f()
{
  S<L<int> > i;
  i.f(0);
}
// Error: ';' expected following '}' of definition of class 'N<int >'

inline void A::g()
{ }

int main()
{
  A a;
  a.f();

  return 0;
}


Occurs when trying to compile Boost's signals library. Workaround is to add
the "missing" ';'.

BTW, should these bug reports be posted here or in c++.beta?


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Jan 09 2003
parent "Walter" <walter digitalmars.com> writes:
"Christof Meerwald" <cmeerw web.de> wrote in message
news:avjt6h$1k7h$1 digitaldaemon.com...
 BTW, should these bug reports be posted here or in c++.beta?

When I put out the next beta, yes.
Jan 09 2003