pointer to SPECIALIZED member function template not legal c++ ? | Bytes (2024)

Ingo

Hi,

the following code:
template< typename objectT
, typename worldT >
void(objectT::* getInvocationFunctionFor( objectT* v ))(worldT&)
{
return &(objectT::custom_func/*<worldT>*/);
}

will work unless I activate the commented template arg.

Only exception is VC++, but GCC 4.x and Comeau won't take it.

I would like to know, whether there is a good reason for making this
illegal and whether somebody knows a nice workaround. Or did I do
something stupid here?

Ingo

Oct 19 '08 #1

3 pointer to SPECIALIZED member function template not legal c++ ? | Bytes (1) 2503 pointer to SPECIALIZED member function template not legal c++ ? | Bytes (2)

acehreli

On Oct 19, 2:29*pm, Ingo <Ingo.Nol...@recurdyn.dewrote:

template< typename objectT
* * * * * * * * * * * * * * * * , typename worldT >
void(objectT::* getInvocationFunctionFor( objectT* v ))(worldT&)
{
* * * * return &(objectT::custom_func/*<worldT>*/);

}

I recommend using typedef's to make the code readable. I can only fool
myself to think what the return type possibly is. Still, your problem
may be that you are missing a 'template' keyword as in:

return &(objectT::template custom_func<worldT>);

Without that, the compiler would take '<' as the "less than" operator.

Ali

Oct 19 '08 #2

Ingo

>
I recommend using typedef's to make the code readable. I can only fool
myself to think what the return type possibly is. Still, your problem

Could you tell me how to do that??

The return type is a pointer to a member function. The argument of
that member function depends on functions actual template arguments.
Since there is no templated typedef, how would you use a typedef in
this situation?

may be that you are missing a 'template' keyword as in:

* *return &(objectT::template custom_func<worldT>);

Without that, the compiler would take '<' as the "less than" operator.

Thank you,
this did it. Should have been obvious to me. I just spend too much
time coding with vc.

Ingo

Ali

Oct 20 '08 #3

Hendrik Schober

Ingo wrote:

>I recommend using typedef's to make the code readable. I can only fool
myself to think what the return type possibly is. Still, your problem

Could you tell me how to do that??

The return type is a pointer to a member function. The argument of
that member function depends on functions actual template arguments.
Since there is no templated typedef, how would you use a typedef in
this situation?

The common workaround is to use a traits class.

[...]

Schobi

Oct 20 '08 #4

Create Post

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5 2925

pointer to template function

by: Suzanne Vogel |last post by:

Is it possible to store a pointer to a template function? eg, template<class T> fooFunc() {...} fptr = fooFunc; // <-- I couldn't find any info here, not even in the forums:...

C / C++

1 4475

Pointer-to-member as template argument

by: Adam Dziendziel |last post by:

Hi all! I'm writing a luabind/boost::python-like binding utility for a Squirrel language to generating wrapper-functions for C++ classes and have a problem with passing the pointer-to-member...

C / C++

6 1507

types of a pointer

by: Nico Kruithof |last post by:

Hello, I have the following problem. Assume I have a templated class (B) that is parameterized by a pointer to another class (A), how can I obtain information of the types of A within B? This...

C / C++

3 3684

pointer is std:map - broke in port from VS6 to .NET - A little Help?

by: Dan Trowbridge |last post by:

Hi everyone, In my attempt to port code from VS 6.0 to VS.NET I had some code break along the way, mostly due to not adhereing closely to the C++ standard. This may be another instance but I...

.NET Framework

5 2246

Various template approaches to avoid pointer to function penalty

by: StephQ |last post by:

This is from a thread that I posted on another forum some days ago. I didn't get any response, so I'm proposing it in this ng in hope of better luck :) The standard explanation is that pointer...

C / C++

2 3694

'function' : cannot be explicitly specialized error

by: Aarti |last post by:

Say I have a class template as follows template<typename T> class foo { public: void test(); }; template<typename T>

C / C++

12 540

Pointer to class data member question

by: WaterWalk |last post by:

Hello. I am rather confused by the type of a pointer to class data member. Many c++ texts say that pointer to data member has a special syntax. For example the following class: class MyClass {...

C / C++

921

pointer to memb func not enough for implicit instantiation?

by: Francesco |last post by:

Hi to all, The code below is a ( very ) simplified example of the problem I'm facing. // CODE template< typename T > class A { public:

C / C++

7 3787

Function pointer help

by: ghulands |last post by:

I am having trouble implementing some function pointer stuff in c++ An object can register itself for many events void addEventListener(CFObject *target, CFEventHandler callback, uint8_t...

C / C++

7076

What is ONU?

by: marktang |last post by:

ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

General

6932

Changing the language in Windows 10

by: Hystou |last post by:

Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

Windows Server

7094

Problem With Comparison Operator <=> in G++

by: Oralloy |last post by:

Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

C / C++

7131

Maximizing Business Potential: The Nexus of Website Design and Digital Marketing

by: jinu1996 |last post by:

In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

Online Marketing

1 6789

The easy way to turn off automatic updates for Windows 10/11

by: Hystou |last post by:

Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

Windows Server

1 4821

Access Europe - Using VBA to create a class based on a table - Wed 1 May

by: isladogs |last post by:

The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

Microsoft Access / VBA

4519

Couldn’t get equations in html when convert word .docx file to html file in C#.

by: conductexam |last post by:

I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

C# / C Sharp

3030

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

226

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

by: bsmnconsultancy |last post by:

In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

General

pointer to SPECIALIZED member function template not legal c++ ? | Bytes (2024)
Top Articles
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5531

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.