Boost logo

Boost :

Subject: [boost] [system] error_code.hpp - questionable includes
From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2010-06-04 03:38:57


Hi,

I noticed that system/error_code.hpp caused some unexpected increase in
compilation time, and looked trough its includes.

The following seems not needed:

#include <boost/cstdint.hpp>
#include <boost/assert.hpp>
#include <boost/operators.hpp>
#include <boost/noncopyable.hpp> // 1)
#include <stdexcept>
#include <functional> // 2)

1)
noncopyable is used to tell that a class (error_category) with pure virtual
functions cannot be copied.
This is implicit in the language, so really not needed. Unless there's a
compelling reason to make sure derived classes can't
be copyable either, but I didn't see any reason for this? I didn't look very
close though, could've missed it.

2)
inclusion of <functional> seems only needed to have the following:
      bool operator<( const error_category & rhs ) const
      {
        return std::less<const error_category*>()( this, &rhs );
      }
I can't guess the reason for using std::less instead of simply writing '<',
but surely it can be expressed without std::less, no?

And before getting the common Booster's answer when asking to remove
#includes:
Yes, I am aware of precompiled headers. I use them, too. =)

Cheers,
Christian

P.S. Would it be too much to ask for having a separate header for the
error_code's ostream operators?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk