|
Boost : |
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-08-20 18:07:30
Michael Marcin wrote:
> The VC team recently released an update to the VC9 standard library that
> allows them to take advantage of types with fast swap when performing
> operations like vector realloc. However it appears this optimization is
> guarded by a trait that must be specialized.
>
> Could we specialize std::_Move_operation_category for this version of
> VC9 to enable this optimization for boost types that can benefit from it?
>
> http://tinyurl.com/6h298c
>
I try to stay away from the preprocessor so maybe someone can take this
an extend it but how about something like:
#if defined(_MSC_VER)
# if( _MSC_FULL_VER == 150030729 && _MSC_BUILD == 1 )
// enables fast swap optimization for vc9 sp1
# include <xutility>
# define BOOST_MSVC_FAST_SWAP_OPTIMIZATION( Class, Arg ) \
namespace std \
{ \
template< class Arg > \
class _Move_operation_category< Class< Arg > > \
{ \
public: \
typedef _Swap_move_tag _Move_cat; \
}; \
}
# elif defined(BOOST_DETECT_OUTDATED_WORKAROUNDS) && (_MSC_FULL_VER >
150030729)
# error "MSVC version is newer than VC9 SP1 if the fast swap
optimization still needs to be enabled update the version numbers"
# endif
#endif
#if !defined(BOOST_MSVC_FAST_SWAP_OPTIMIZATION)
# define BOOST_MSVC_FAST_SWAP_OPTIMIZATION( Class, Args )
#endif
Then take for instance boost/shared_ptr.hpp and add
BOOST_MSVC_FAST_SWAP_OPTIMIZATION( boost::shared_ptr, T )
Thanks,
Michael Marcin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk