473,405 Members | 2,261 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,405 software developers and data experts.

pointer to memb func not enough for implicit instantiation?

Hi to all,

The code below is a ( very ) simplified example of the problem I'm
facing.

// CODE
template< typename T >
class A
{
public:
void Do() {}
};

template< typename T >
class B
{
public:
void Do()
{
A< int > obj;
void ( A< int >::*pmf )() = &A< int >::Do;
( obj.*pmf )();
// pmf not sufficient to instantiate memb func?
//return; A< int >().Do(); // WITH THIS IT LINKS
}

};

int main()
{
B< char > obj;
obj.Do();
}
// END CODE

This compiles fine but does not link: missing symbol A< int >::Do
referenced from B< char >::Do.
Basically it seems that a pointer to a member function of a template
class, referenced from a member function of another template class is
not enough to instantiate the first member function.

I've tried to take a look at the standard [temp.inst] 14.7.1 and it
says
"Unless a member of
a class template or a member template has been explicitly instantiated
or explicitly specialized, the specialization of the
member is implicitly instantiated when the specialization is
referenced in a context that requires the member deļ¬nition
to exist"

My naive interpretation is that the code above should work...

I'm using GCC 4.0 on XCode 3.1 (Mac OS X). I was wondering if there is
a compiler option that forces instantiation in cases like this...

Probably I'm missing something.... any help, suggestion or advice
would be greatly appreciated ( as usual...)
Thanks in advance,
Francesco
Sep 11 '08 #1
0 917

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

Similar topics

90
by: Mark Hahn | last post by:
"Michael Geary" <Mike@Geary.com> wrote ... >Does anyone have some sample code where obj$func() would be used? > (Apologies if I missed it.) There have been so many messages about delegation...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
18
by: man | last post by:
can any one please tell me what is the diff between pointer and reference.....and which one is better to use ....and why???????
12
by: johnsolver | last post by:
Hi I hope I got the topic right.. that's what I'm doing: create P(variable) polygons each having a variable numbers of vertices, something in my mallocs is wrong... since I get weird results. ...
9
by: Allen | last post by:
Hi, I want to know How to create an associated array using map with keys are string, values are function pointers with same arguments, but each function belong to different class. The map need to...
42
by: xdevel | last post by:
Hi, if I have: int a=100, b = 200, c = 300; int *a = {&a, &b, &c}; than say that: int **b is equal to int *a is correct????
11
by: Antoninus Twink | last post by:
What's the correct syntax to define a function that returns a pointer to a function? Specifically, I'd like a function that takes an int, and returns a pointer to a function that takes an int and...
19
by: =?iso-8859-1?b?VG9t4XMg0yBoyWlsaWRoZQ==?= | last post by:
Coming originally from C++, I used to do the likes of the following, using a pointer in a conditional: void Func(int *p) { if (p) { *p++ = 7; *p++ = 8;
5
by: Tim Frink | last post by:
Hi, I'm experimenting with function pointers and found two questions. Let's assume this code: 1 #include <iostream> 2 class A; 3 4 //////////////////////////////////////////// 5 class B
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
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...
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
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...
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.