Definitions of interface classes
Alan Griffiths
alan.griffiths at canonical.com
Tue Mar 26 11:13:03 UTC 2013
On 26/03/13 10:00, Alexandros Frantzis wrote:
> Hi all,
>
> in the code we use a couple of slightly different ways to define
> interface classes. Although the variations are mostly equivalent
> functionally, it would be nice to decide on a standard way and add
> it to the coding guide. The variation I see mostly (and use) is:
>
> class Interface
> {
> public:
> virtual ~Interface() {}
>
> virtual void method1() = 0;
> virtual void method2() = 0;
>
> protected:
> Interface() = default;
> Interface(Interface const&) = delete;
> Interface& operator=(Interface const&) = delete;
> };
>
> There was also some discussion about using:
>
> virtual ~Interface() = default;
This is my preference
> because of the noexcept guarantee.
This is why.
> Thoughts?
It does mean that derived classes (including mocks) need a "noexcept"
destructor. That can cause a cascade of changes and means mocks need an
explict noexcept destructor.
More information about the Mir-devel
mailing list