mercredi 23 mai 2018

forward declare a typedef protection

I am attempting to forward declare some variables used only privately in a class to limit the number of headers that I have to include when using this one.

Sadly, the class that I want to forward declare has turned out to be a typedef, and it's a 3rd party library that I can't edit (let's call it "boost::asio::strand" for the sake of argument)

This question Forward declaration of a typedef in C++ Demonstrates that the only solutions are either:

  • Just include the header and accept it's not possible
  • Forward declare what would be typedef'ed and add my own typedef

Looking at the second solution, is there any way that I can protect myself from the typedef changing in the library so that the compiler complains about the typedef rather than the usage of an undefined type when the class is removed/renamed and make it less of a maintenance headache?

Aucun commentaire:

Enregistrer un commentaire