mirror of
https://github.com/boostorg/more.git
synced 2025-01-27 04:30:05 +08:00
instantiating a template with a member function pointer
[SVN r13042]
This commit is contained in:
parent
d97529e059
commit
933a719686
@ -284,6 +284,36 @@ int main()
|
||||
either taking a value or a reference parameter.
|
||||
|
||||
|
||||
<h3>[instantiate memfun ptr] Instantiation with member function pointer</h3>
|
||||
|
||||
When directly instantiating a template with some member function
|
||||
pointer, which is itself dependent on some template parameter, the
|
||||
compiler cannot cope:
|
||||
<pre>
|
||||
template<class U> class C { };
|
||||
template<class T>
|
||||
class A
|
||||
{
|
||||
static const int v = C<void (T::*)()>::value;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<strong>Workaround:</strong> Use an intermediate <code>typedef</code>:
|
||||
|
||||
<pre>
|
||||
template<class U> class C { };
|
||||
template<class T>
|
||||
class A
|
||||
{
|
||||
typedef void (T::*my_type)();
|
||||
static const int v = C<my_type>::value;
|
||||
};
|
||||
</pre>
|
||||
|
||||
(Extracted from e-mail exchange of David Abrahams, Fernando Cacciola,
|
||||
and Peter Dimov; not actually tested.)
|
||||
|
||||
|
||||
<h2>Library</h2>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user