From 84e8d4b6296bbf381d7f721f06a58333b694a792 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 24 Jun 2019 14:12:50 -0400 Subject: [PATCH] Rewrite AttachedVirtualFunction so MS compiler accepts it --- src/AttachedVirtualFunction.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/AttachedVirtualFunction.h b/src/AttachedVirtualFunction.h index 20b667ed8..c2603e4de 100644 --- a/src/AttachedVirtualFunction.h +++ b/src/AttachedVirtualFunction.h @@ -135,15 +135,10 @@ class AttachedVirtualFunction { 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 // in each override using Object = This; - using Function = ImplementationFor< This >; + using Function = std::function< Return( Object&, Arguments... ) >; // A function returning a std::function, which you define elsewhere; // it may return nullptr in case this must act somewhat as a "pure virtual", // throwing InconsistencyException if the function is invoked on a subclass @@ -167,6 +162,7 @@ public: struct Override : Overridden { using Object = Subclass; + using Function = std::function< Return( Object&, Arguments... ) >; // Check that inheritance is correct static_assert( @@ -174,7 +170,6 @@ public: "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 static Function Implementation(); // May be used in the body of the overriding function, defining it in @@ -230,7 +225,7 @@ public: private: 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 GetRegistry().push_back({ @@ -244,7 +239,7 @@ private: struct Entry { Predicate predicate; - ImplementationFor< This > function; + Function function; }; using Registry = std::vector< Entry >;