mirror of
https://github.com/boostorg/boost.git
synced 2025-04-14 17:03:38 +00:00
instantiating a template with a member function pointer
[SVN r13042]
This commit is contained in:
parent
c17a925c4e
commit
75e579f1bf
1 changed files with 30 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue