|
Boost : |
Subject: [boost] generally replace *static_cast< T [const]* >(&x) -> static_cast< T [const]& >(x)?
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2011-05-25 08:22:59
>>
>> --- C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/boost_1_46_1/boost/iterator/iterator_facade.hpp Wed May 25 11:42:14 2011
>> +++ C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/boost_1_46_1/boost/iterator/iterator_facade - Copy.hpp Wed May 25 11:41:49 2011
>> @@ -819,8 +819,8 @@
>> is_interoperable< Derived1, Derived2>::value \
>> )); \
>> return_prefix iterator_core_access::base_op( \
>> - *static_cast<Derived1 const*>(&lhs) \
>> - , *static_cast<Derived2 const*>(&rhs) \
>> + static_cast<Derived1 const&>(lhs) \
>> + , static_cast<Derived2 const&>(rhs) \
>> , BOOST_ITERATOR_CONVERTIBLE(Derived2,Derived1) \
>> ); \
>> }
>An alternative could also have been to use boost::addressof
I was aware of that, but creating the dependency on addressof seems unnecessary if a simple reference cast does the job. Is there any particular reason why the cast is implemented through pointers?
Searching through boost for *static_cast, there are a few more places where a static_cast< [const] & > would do but the route through pointers has been taken. Any reason not to replace them wholesale to avoid problems with overloaded operator& and in general to make the code more concise?
boost_1_46_1\boost\accumulators\framework\depends_on.hpp(276): : Accumulator(*static_cast<Accumulator const *>(&that))
boost_1_46_1\boost\accumulators\framework\accumulators\droppable_accumulator.hpp(183): : Accumulator(*static_cast<Accumulator const *>(&that))
boost_1_46_1\boost\algorithm\string\classification.hpp(246): *static_cast<const Pred1T*>(&Pred1),
boost_1_46_1\boost\algorithm\string\classification.hpp(247): *static_cast<const Pred2T*>(&Pred2) );
boost_1_46_1\boost\algorithm\string\classification.hpp(270): *static_cast<const Pred1T*>(&Pred1),
boost_1_46_1\boost\algorithm\string\classification.hpp(271): *static_cast<const Pred2T*>(&Pred2));
boost_1_46_1\boost\algorithm\string\classification.hpp(289): return detail::pred_notF<PredT>(*static_cast<const PredT*>(&Pred));
boost_1_46_1\boost\iterator\iterator_facade.hpp(570): return *static_cast<I*>(&facade);
boost_1_46_1\boost\iterator\iterator_facade.hpp(576): return *static_cast<I const*>(&facade);
boost_1_46_1\boost\iterator\iterator_facade.hpp(732): tmp(*static_cast<I*>(&i));
boost_1_46_1\boost\iterator\iterator_facade.hpp(822): *static_cast<Derived1 const*>(&lhs) \ //// our problem
boost_1_46_1\boost\iterator\iterator_facade.hpp(823): , *static_cast<Derived2 const*>(&rhs) \ //// our problem
boost_1_46_1\boost\xpressive\detail\static\static.hpp(104): return *static_cast<stacked_xpression<Top, Next> const *>(&next);
Arno
-- Dr. Arno Schödl | aschoedl_at_[hidden] Technical Director think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091 Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk