mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-11 17:41:15 +02:00
Rewrite AttachedVirtualFunction so MS compiler accepts it
This commit is contained in:
parent
e08a942ab8
commit
84e8d4b629
@ -135,15 +135,10 @@ class AttachedVirtualFunction
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// The type of an overriding function, taking a more specific first
|
|
||||||
// argument
|
|
||||||
template< typename Subclass >
|
|
||||||
using ImplementationFor = std::function< Return( Subclass&, Arguments... ) >;
|
|
||||||
|
|
||||||
// These member names are declared in this class template and redeclared
|
// These member names are declared in this class template and redeclared
|
||||||
// in each override
|
// in each override
|
||||||
using Object = This;
|
using Object = This;
|
||||||
using Function = ImplementationFor< This >;
|
using Function = std::function< Return( Object&, Arguments... ) >;
|
||||||
// A function returning a std::function, which you define elsewhere;
|
// A function returning a std::function, which you define elsewhere;
|
||||||
// it may return nullptr in case this must act somewhat as a "pure virtual",
|
// it may return nullptr in case this must act somewhat as a "pure virtual",
|
||||||
// throwing InconsistencyException if the function is invoked on a subclass
|
// throwing InconsistencyException if the function is invoked on a subclass
|
||||||
@ -167,6 +162,7 @@ public:
|
|||||||
struct Override : Overridden
|
struct Override : Overridden
|
||||||
{
|
{
|
||||||
using Object = Subclass;
|
using Object = Subclass;
|
||||||
|
using Function = std::function< Return( Object&, Arguments... ) >;
|
||||||
|
|
||||||
// Check that inheritance is correct
|
// Check that inheritance is correct
|
||||||
static_assert(
|
static_assert(
|
||||||
@ -174,7 +170,6 @@ public:
|
|||||||
"overridden class must be a base of the overriding class"
|
"overridden class must be a base of the overriding class"
|
||||||
);
|
);
|
||||||
|
|
||||||
using Function = ImplementationFor< Subclass >;
|
|
||||||
// A function returning a std::function that must be defined out-of-line
|
// A function returning a std::function that must be defined out-of-line
|
||||||
static Function Implementation();
|
static Function Implementation();
|
||||||
// May be used in the body of the overriding function, defining it in
|
// May be used in the body of the overriding function, defining it in
|
||||||
@ -230,7 +225,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
template< typename Subclass >
|
template< typename Subclass >
|
||||||
static void Register( const ImplementationFor< This > &function )
|
static void Register( const Function &function )
|
||||||
{
|
{
|
||||||
// Push back a dynamic type test and corresponding function body
|
// Push back a dynamic type test and corresponding function body
|
||||||
GetRegistry().push_back({
|
GetRegistry().push_back({
|
||||||
@ -244,7 +239,7 @@ private:
|
|||||||
struct Entry
|
struct Entry
|
||||||
{
|
{
|
||||||
Predicate predicate;
|
Predicate predicate;
|
||||||
ImplementationFor< This > function;
|
Function function;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Registry = std::vector< Entry >;
|
using Registry = std::vector< Entry >;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user