I have read many similar questions related to this (including this insightful one: What's the difference between "= default" destructor and empty destructor?), but none have quite answered my particular case. Do they differ according to how they're implemented by the compiler? If this is being used as part of a shared library, what's the best way to make the code portable? I'm also wondering if both cases inline the destructor - I think they do, but I'm not sure.
Is there any difference between these two pieces of code?
// Case 1
struct BaseClass {
virtual ~BaseClass() = default;
virtual void func (int a) = 0;
shared_ptr<BaseClass> next;
};
// Case 2
struct BaseClass {
virtual ~BaseClass() {};
virtual void func (int a) = 0;
shared_ptr<BaseClass> next;
};
Both return "false" when I check them with std::is_trivially_destructible::value, so I know they are both non-trivial.
Thank you.