
2013/11/7 Viktor Sehr
Thanks for the response, I've updated the class to utilize boost::swap, boost::move and also marked move\swap function as noexcept.
Marking methods with BOOST_NOEXCEPT by default is not the right way. noexcept specification depends on types that are stored in class, so noexcept specification of methods must be detected using TypeTraits and other magic. Something like this: BOOST_NOEXCEPT_IF(/*some expression to detect that operations for type 1 won't throw, like `boost::is_nothrow_move_constructible<Type1>::value`*/ && /*same stuff for all other types*/ ) This is a lot of work to do... But it is not critical at the moment. Following issues must be solved before the macro could be officially reviewed by community: * Header DefaultEverything.h requires include guards, hpp extension and must be lower-case. * DEFAULT_EVERYTHING does not creates a copy constructor. * There are some policies that must be followed: http://www.boost.org/development/requirements.html For example all the macro must have BOOST_ prefix and so on. * tests must be provided I'm thinking about extending it for pod-classes (only provide
comparisson\sort) and perhaps move-only classes. Also perhaps a constructor which takes all member variables as parameters (especially in the pod-case it's probably useful)?
Sounds not bad. I'd also like to have a macro that generates move assignment and assignment operators using member swap and constructors. Something like the following: #define BOOST_GENERATE_ASSIGNMENTS(classname) \ classname& operator=(BOOST_COPY_ASSIGN_REF(classname) other) \ BOOST_NOEXCEPT_IF(boost::is_nothrow_constructible<classname>::value \ && boost::is_nothrow_member_swappable<classname>::value) \ { \ classname(other).swap(*this); \ return *this; \ } \ classname& operator=(BOOST_RV_REF(classname) other) \ BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<classname>::value \ && boost::is_nothrow_member_swappable<classname>::value) \ { \ classname(boost::move(other)).swap(*this); \ return *this; \ } \ /**/ -- Best regards, Antony Polukhin