|
Boost : |
Subject: Re: [boost] [type_traits] has_equal_to< std::vector<T> > always true_
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2012-07-04 22:31:31
On 04/07/12 15:12, Lorenzo Caminiti wrote:
<snip>
> Also, if I forward declare the templates I need from STL, I don't need
> to #include the STL. This way there is no draw back in declaring the
> specializations directly in boost/type_traits/has_equal_to.hpp (or, is
> there?)
As discussed elsewhere in this thread, unfortunately it's not conformant
to forward-declare things in the std namespace. There's a boost header
boost/detail/container_fwd.hpp that will do it for those libraries which
allow it, but as you can see if you look in it there are lots of cases
where it's not possible. So some users will end up paying the cost of
including those headers.
> instead that in a separate header
> boost/type_traits/std/vector.hpp. The advantage of this is that
> boost::has_equal_to<vector<T> > will do what the user expects "out of
> the box" and without requiring the user to know and remember to
> include the extra header type_traits/std/vector.hpp.
I think the situation is a bit worse than you suggest. If the user
sometimes forgets to include the extra header then his program might
well end up violating the one definition rule. For that reason I would
strongly recommend including the specializations along with the
definition of has_equal_to, which unfortunately has the aforementioned
cost of extra #includes in some cases.
John Bytheway
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk