Yesterday I posted a paper to the mailing list for proposals for the C++ Standard. You can download the latest draft of my paper from:
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(); }
};
And a excerpt of the explanation:
Downcasting at compile-time from a Base class to a Derived class works fine when the following two criteria are met:
1) The Derived class does not add any additional member objects
2) The Derived class does not define or override any virtual functions
When these two criteria are met, it is always safe to downcast at compile-time from Base to Derived.
In these circumstances, the Derived class is free to:
a) Define a non-virtual function with a new name that doesn’t exist in the Base class
b) Define a non-virtual function to override a non-virtual function of the same name in the Base class