473,888 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::*pF uncPtr) () = TestClass<0>::S omeFunc;

Thanks in advance,
Stuart
Feb 13 '07 #1
2 2366
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::*pF uncPtr) () = TestClass<0>::S omeFunc;
Two suggestions:

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

void (TestClass::*pF uncPtr) () = &TestClass::Som eFunc<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::*pF uncPtr) () = TestClass<0>::S omeFunc;


Two suggestions:

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

void (TestClass::*pF uncPtr) () = &TestClass::Som eFunc<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
2097
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 be very appreciated. cheers domenico
3
1969
by: Brian Riis | last post by:
Given: template <typename T1, typename T2> class A { public: template <int I> void B(); };
5
6595
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
2302
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 the data member is the same for every instance of that class? I would expect so, but I noticed something that makes me doubt a little.
4
4071
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 #ifndef TEST_HEADER_H #define TEST_HEADER_H
3
1225
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 code demonstrates what I'd like to to: #include <iostream> template<class T> struct BarA {
3
2930
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 T,typename Alloc = std::allocator<T class CircularBuffer4 { public: typedef typename CircularBuffer<T,Alloc>::size_type
2
2063
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 error C1001: internal compiler error. // (File "msc1.cpp", Line 1392)
2
7709
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
9961
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11180
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7990
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5817
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.