O'Reilly logo
  • Chris Kang thinks this is interesting:

For example, if you use forward declares for a foreign header and your API is used in environments with different versions of that header, the declaration of a class within that header could be changed to a typedef or the class could be changed to a templated class, which would break your forward declaration. This is one reason why you should specifically never try to forward declare STL objects,


Cover of API Design for C++


There are different implementation of std library so that when your forward declare, your code may work differently based on the std library that you link with. Especially, the library you're linking with happens to have same type defined as template type. Even if you intend to use them as template type, if someone applies different type for the template type, the behaviour of your code can change or not work at all.