|
Boost : |
From: shunsuke (pstade.mb_at_[hidden])
Date: 2007-09-28 09:14:29
Sean Huang wrote:
> The following simple problem produces an error when compiling with VC8+SP1
> on Windows:
>
> #include <vector>
> #include <boost/range/sub_range.hpp>
>
> int main(int argc, char* argv[])
> {
> typedef std::vector< int > VectorType;
> VectorType v;
> boost::sub_range< VectorType > range;
> boost::sub_range< VectorType > range1;
> range = range1;
> return 0;
> }
sub_range copy-constructor is broken under msvc.
(BTW, a singular(uninitialized) sub_range can't be assigned to another.)
I've ever looked into this problem.
See:
The implicitly-defined coyp-constructor shall be something like this:
sub_range(sub_range const &from) :
super(static_cast<super const &>(from)) // calls "normal" copy-constructor of super type.
{ }
But I guess msvc8(maybe also msvc7.1) generates:
sub_range(sub_range const &from) :
super(from) // overload resolution of super type constructors kicks in.
{ }
super type(iterator_range) doesn't know the sub_range type.
Now sub_range is const-qualified, hence it can't be copied to mutable iterators.
Ditto copy-assignment operator.
The workaround is to write copy-constructor/assignment "by hand".
In fact, this can't explain the exact behavior of msvc.
My sub_range seems to work well, though.
Regards,
-- Shunsuke Sogame
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk