Date: Tue, 20 Feb 2024 09:49:08 +0000
I had a header file "record.h" something like as follows:
class IDevice;
int Record( IDevice * );
I put in a forward declaration for 'IDevice, because I didn't want to
include the header file that defines 'IDevice' for two reasons:
(1) To reduce compile time
(2) To avoid a circular dependency
This worked fine until the person who maintained 'IDevice' did the
following inside "IDevice.hpp":
template<bool temp_param_record>
class Interface {
public:
static consteval bool record(void) noexcept { return
temp_param_record; }
};
typedef Interface<true> IDevice;
So now any source file that does the following:
#include "IDevice.h"
#include "record.h"
fails to compile. So I propose that the following be valid C++:
class Monkey;
int Func(Monkey *const p)
{
return nullptr == p;
}
class Donkey {
int number;
};
typedef Donkey Monkey;
int main(void)
{
Monkey obj;
}
I propose that we should be able to do a forward declaration of a
typedef'ed class.
class IDevice;
int Record( IDevice * );
I put in a forward declaration for 'IDevice, because I didn't want to
include the header file that defines 'IDevice' for two reasons:
(1) To reduce compile time
(2) To avoid a circular dependency
This worked fine until the person who maintained 'IDevice' did the
following inside "IDevice.hpp":
template<bool temp_param_record>
class Interface {
public:
static consteval bool record(void) noexcept { return
temp_param_record; }
};
typedef Interface<true> IDevice;
So now any source file that does the following:
#include "IDevice.h"
#include "record.h"
fails to compile. So I propose that the following be valid C++:
class Monkey;
int Func(Monkey *const p)
{
return nullptr == p;
}
class Donkey {
int number;
};
typedef Donkey Monkey;
int main(void)
{
Monkey obj;
}
I propose that we should be able to do a forward declaration of a
typedef'ed class.
Received on 2024-02-20 09:49:20