473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Taking address of member template function.

Hello newsgroup,

I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}
};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;

Thanks in advance,
Stuart
Feb 13 '07 #1
2 2350
On Feb 13, 10:16 am, Stuart Redmann <DerTop...@web.dewrote:
I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}

};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;
Two suggestions:

1. Your syntax is wrong. Change the last line to:

void (TestClass::*pFuncPtr) () = &TestClass::SomeFunc<0>;

2. Get a new compiler - Visual C++ 6.0 is horribly out of date.

Best regards,

Tom

Feb 13 '07 #2
Thomas Tutone wrote:
On Feb 13, 10:16 am, Stuart Redmann <DerTop...@web.dewrote:
>>I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}

};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;


Two suggestions:

1. Your syntax is wrong. Change the last line to:

void (TestClass::*pFuncPtr) () = &TestClass::SomeFunc<0>;
That is what I was afraid of: With this syntax I get
fatal error C1001: INTERNAL COMPILER- ERROR
2. Get a new compiler - Visual C++ 6.0 is horribly out of date.
I will. Honestly.

Thanks,
Stuart
Feb 13 '07 #3

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

Similar topics

2
by: Domenico Andreoli | last post by:
hello, i have the following problem: taking the pointer of a particular instantiation of template member function A::f. i have no idea of how achieve in the intent. :( any halp or hint would...
3
by: Brian Riis | last post by:
Given: template <typename T1, typename T2> class A { public: template <int I> void B(); };
5
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
1
by: Frederiek | last post by:
Hi, When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. Does that mean that the address of...
4
by: James Aguilar | last post by:
Guys, When I specialize a template class member function (I.e. a member function of a template class) based on that class' type, bad things happen. Here's some code: ---- test_header.h...
3
by: =?iso-8859-1?q?Erik_Wikstr=F6m?= | last post by:
I'd like to create a partial specialization of a member-method of a parameterized class which takes a parameterized argument, but I'm not sure if it's possible or, if possible, how. The following...
3
by: toton | last post by:
Hi, I want to specialize template member function of a template class . It is creating some syntax problem .... Can anyone say how to do it ? The class is something like this template<typename...
2
by: pascal.zschumme | last post by:
hello folks My problem is that the following code using something very very difficult technique :D fails to compile on MSVC8: <code> // main.cpp // // the error is: // main.cpp(8) : fatal...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.