From 933a719686b5605dd25cdf2b6463cd0adae51c0f Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Sun, 3 Mar 2002 10:11:32 +0000 Subject: [PATCH] instantiating a template with a member function pointer [SVN r13042] --- borland_cpp.html | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/borland_cpp.html b/borland_cpp.html index 6efb1a2..afe1e61 100644 --- a/borland_cpp.html +++ b/borland_cpp.html @@ -284,6 +284,36 @@ int main() either taking a value or a reference parameter. +

[instantiate memfun ptr] Instantiation with member function pointer

+ +When directly instantiating a template with some member function +pointer, which is itself dependent on some template parameter, the +compiler cannot cope: +
+template<class U> class C { };
+template<class T>
+class A
+{
+  static const int v = C<void (T::*)()>::value;
+};
+
+ +Workaround: Use an intermediate typedef: + +
+template<class U> class C { };
+template<class T>
+class A
+{
+  typedef void (T::*my_type)();
+  static const int v = C<my_type>::value;
+};
+
+ +(Extracted from e-mail exchange of David Abrahams, Fernando Cacciola, +and Peter Dimov; not actually tested.) + +

Library