Removing ‘#include ‘ doesn’t break the code

The reason it works is because has been included by a header that you have also included.

For example vector might have included algorithms in it’s source. This is common as they are often header only.

That said, you can not rely on the specific implementation of the standard library to have the same includes in each header. (for example with might work with MSVC and it might break with gcc stdlibc+++).

For this reasons I highly recommend including what you use, regardless of where it will compile of not. — note that this is slightly different to ‘what you reference’ because forward declaration for point and references in headers can significantly improve build time.

Leave a Comment