[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Template woos
From: |
André Pönitz |
Subject: |
Template woos |
Date: |
31 Jan 2002 10:39:40 GMT |
// The following works:
template <class S, class Base>
struct IsDerivedFrom {
struct No {};
struct Yes { No n_[3]; };
struct Helper {
static Yes Test(Base*);
static No Test(...);
};
enum { value = sizeof(Yes) == sizeof( Helper::Test(static_cast<S*>(0))
) };
};
// This does not but I think it should:
template <class S, class Base>
struct IsDerivedFrom {
struct No {};
struct Yes { No n_[3]; };
static Yes Test(Base*);
static No Test(...);
enum { value = sizeof(Yes) == sizeof( Test(static_cast<S*>(0)) ) };
};
This is tested with 2.95 and 3.0.2 and both give the error
d.C: In instantiation of `IsDerivedFrom<X, HasBar>':
d.C:48: instantiated from `void foo(const T&) [with T = X]'
d.C:56: instantiated from here
d.C:48: invalid use of undefined type `struct IsDerivedFrom<X, HasBar>'
d.C:21: forward declaration of `struct IsDerivedFrom<X, HasBar>'
(with different line numbers, though)
Is this a compiler bug or is the code indeed wrong?
Andre'
--
André Pönitz .............................................. address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Template woos,
André Pönitz <=