I am implementing a type T. Although this is not a requirement, users of this type may benefit from move semantic, that is T(T&&) and T& operator=(T&&).
Since T contains std::function's as member data, I cannot implement move semantic with the noexcept guarantees, which would make T less useful for the user.
Also, for the above reason, my implementation cannot be as simple as: T(&&) noexcept = default and T& operator=(T&&) noexcept = default
The alternative would be to either offer the user the non-noexcept versions: T(&&) = default and T& operator=(T&&) = default; or implement my user defined noexcept move semantic in terms of std::function::swap() (which is guaranteed to be noexcept). In the latter case, I would unfortunately have to take care of all the other member data other than std::function's (ugly!).
So, there are three options:
- disable move semantic at all
- implement
T(&&) = defaultandT& operator=(T&&) = default - implement my own
T(&&) noexcept {/* lot of code */}andT& operator=(T&&) noexcept {/* lot of code */}
I know the question is rather subjective, but What would you opt for?
Aucun commentaire:
Enregistrer un commentaire