Boost logo

Boost :

Subject: Re: [boost] [system] error_code.hpp - questionable includes
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-06-04 11:40:40


AMDG

Christian Holmquist wrote:
> 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.
>

boost/noncopyable.hpp is only 37 lines
of code and has no dependencies. I highly
doubt that removing it will have any effect
on compile times.

> 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?
>

No it can't. operator< is not guaranteed to behave sanely
for arbitrary pointers. std::less defines a total ordering for
pointers.

In Christ,
Steven Watanabe


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