C++ Logo


Advanced search

Re: [std-proposals] Paper on Interfaces (5 Pages)

From: Julien Villemure-Fréchette <julien.villemure_at_[hidden]>
Date: Thu, 23 Feb 2023 21:08:03 -0500
I think it would clearer and closer to the langue we currently have to simply generalize the alias declarations syntax so that they permit member function (and maybe also data members). This would also close the gap with member using declarations, which are essentially a form of name aliasing (ie, declares a name that refers to another entity). An added benefit is that since we only want to adapt a function name, no function body is needed (even though it would be mostly trivial), no need to specify a full signature (this may be annoying if we need to carry SFINAE, constraints, specially in eventually of refactoring)

For instance:

class stack : private vector
    using pop = vector::pop_back;

    // normal using declaration
    using vector::size;
    // this would be identical to
    // using size = vector::size;

Similar to using declarations within classes, member function aliases may only name base class members.

I haven't included namespace scoped functions for brevity, this is just a starter.

Julien V.

On February 23, 2023 6:52:16 p.m. EST, Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> wrote:
>I've attached to this email the first draft of my paper entitled
>'interfaces', following on from my original post earlier today
>entitled "Allow downcasting at compile time if Derived has no extra
>member objects".
>Also you can download the latest draft from here:
> http://www.virjacode.com/download/interface_latest_draft.pdf
>Here's an excerpt of the syntax:
> interface lockable_bisem : std::binary_semaphore
> {
> void lock(void) noexcept(false) { acquire(); }
> void unlock(void) noexcept(false) { release(); }
> };

Received on 2023-02-24 02:08:13