Date: Tue, 20 Feb 2024 07:36:46 -0300
If you want a non-standard-changing way to do this. Just ask the maintainer
to change:
using IDevice = ifc<true>;
Tô
struct IDevice : public ifc<true> {
using ifc<true>::ifc;
};
(I don't recall if that's the syntax to expose the constructor or if it
needs <true> after the second ifc as well, but you get the idea)
Now you can forward declare IDevice.
Breno G.
Em ter., 20 de fev. de 2024 06:49, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> escreveu:
> 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.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
to change:
using IDevice = ifc<true>;
Tô
struct IDevice : public ifc<true> {
using ifc<true>::ifc;
};
(I don't recall if that's the syntax to expose the constructor or if it
needs <true> after the second ifc as well, but you get the idea)
Now you can forward declare IDevice.
Breno G.
Em ter., 20 de fev. de 2024 06:49, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> escreveu:
> 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.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-02-20 10:36:57