I am aware that we should prefer to forward declare everything in header files, if possible but what about STL?
I have found that for iostream there is iosfwd.
What if i want to have a mutex declared in my class, like this:
class MyClass
{
.....
private:
std::mutex mMutex;
};
Should I include mutex header in my class header? Or is there way to forwarddeclare it, like:
class std::mutex;
class MyClass{...};
Same goes for chrono, and thread as well.
Any thoughts on that is appreacited. Thanks!
There is no portable way to forward declare std::objects, except as specified (e.g. <iosfwd>
). And there are no forwarding headers for mutex
, thread
or chrono
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With