c++stlheader-filesforward-declaration

Forward headers for STL containers


The header <iostream> has a companion <iosfwd> which is sufficient if I only need pointers or references to streams. The latter is a common scenario when overloading operator<<.

Is there such a header for the STL containers? I want to define a couple of functions that take references to STL containers, and I do not want to include <vector>, <list>, <set> et. al. in their entirety just so I can have references to those types. Are there standard, boost or other solutions to this problem?


Solution

  • No, unfortunately not. The standard only introduced <iosfwd> for backward compatibility to support code that was written for the old, non-templated IO streams library.