Niall Douglas wrote:
I am bothered about the approx 2 seconds per compiland that including
<string> adds if no other STL is being included. In a million file
codebase, that's an extra 23 days of compute time per build. It's
unacceptable.
doesn't need to include <string>. A forward declaration is
enough. User code that calls message() does need to include <string> of
course.
//
template<class E> class char_traits;
template<class T> class allocator;
template class
basic_string;
typedef basic_string<char> string;
class error_category
{
public:
virtual string message( int ev ) const = 0;
};
error_category const& system_category();
class error_code
{
private:
int e_;
error_category const* p_;
public:
error_code() noexcept: e_(0), p_(&system_category()) {}
string message();
};
// <string>
template class basic_string
{
};
// user code
int main()
{
error_code().message();
}
We can't do this in Boost.System because it's not possible to
forward-declare std::string portably, but the standard library can.
Incidentally, have you measured the inclusion time of ?