I wonder if it is possible to use C++11's noexcept operator to define the noextcept specifier of e. g. a destructor that calls a method of another class (e. g. std::allocator::deallocate):
template <class DelegateAllocator = std::allocator<uint8_t>>
class MyAllocator final {
public:
using allocator_type = DelegateAllocator;
// ...
~MyAllocator() noexcept(noexcept(/* what to use */))) {
if (memory_ != nullptr) {
allocator_.deallocate(memory_, length_);
}
}
private:
allocator_type allocator_;
uint8_t* memory_;
// ...
};
Questions: What is the best solution to define noexcept dependent to the used methods of a delegated type (e. g. std::allocator)? What has to be done - when possible - to use methods of a delegated type when different overloads exist (e. g. how would I use a specific deallocate implementation when not only one is provided)?
Aucun commentaire:
Enregistrer un commentaire