Hi Frederick,

 

what is the problem?

The following code compiles just fine:

 

    template<bool temp_param_record>
    class Donkey;

    typedef Donkey<true> Monkey;

    int Func(Monkey *const p)
    {
        returnnullptr == p;
    }

    template<bool temp_param_record>
    class Donkey {
        int number;
    };

    int main(void)
    {
        Monkey obj;
    }
   


 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 20.02.2024 10:49
Betreff: [std-proposals] Allow forward declarations of typedef‘ed classes
An: std-proposals <std-proposals@lists.isocpp.org>;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
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@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals