Hello,
in my class I have a map that translates strings to pointers to some
member functions. The code goes like this:
class F {
typedef void (Function::*MathFuncPtr)();
std::map<std::string, MathFuncPtr> predefinedFunctions;
// lots of other stuff
void makeDictionary(){ predefinedFunctions["sin"]=&F::f_sin(); }
};
Code like this works all right in gcc, but causes a strange compile
time error[*] in VC (from MSVC++ 2005 express beta).
I'd be happy to know if it's my or VC's fault :)
TIA,
Slawek
[*]:
c:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(239) : error
C2065: '_Mycont' : undeclared identifier
c:\Program Files\Microsoft Visual Studio
8\VC\include\xtree(236) : while compiling class template member function
'const std::pair<_Ty1,_Ty2>
&std::_Tree<_Traits>::const_iterator::operator *(void) const'
with
[
_Ty1=const std::string,
_Ty2=Function::MathFuncPtr ,
_Traits=std::_Tmap_traits<std::string,Function::Ma thFuncPtr
,std::less<std::string>,std::allocator<std::pair<c onst
std::string,Function::MathFuncPtr >>,false>
]
c:\Program Files\Microsoft Visual Studio
8\VC\include\xtree(395) : see reference to class template instantiation
'std::_Tree<_Traits>::const_iterator' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,Function::Ma thFuncPtr
,std::less<std::string>,std::allocator<std::pair<c onst
std::string,Function::MathFuncPtr >>,false>
]
c:\Program Files\Microsoft Visual Studio 8\VC\include\map(164)
: see reference to class template instantiation
'std::_Tree<_Traits>::iterator' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,Function::Ma thFuncPtr
,std::less<std::string>,std::allocator<std::pair<c onst
std::string,Function::MathFuncPtr >>,false>
]
c:\Program Files\Microsoft Visual Studio 8\VC\include\map(163)
: while compiling class template member function 'void (Function::*
&std::map<_Kty,_Ty>::operator [](const
std::basic_string<_Elem,_Traits,_Ax> &))(void)'
with
[
_Kty=std::string,
_Ty=Function::MathFuncPtr,
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
d:\Documents and Settings\Serengeti\Moje dokumenty\My
Projects\Derivatives\Derivatives\function.h(36) : see reference to class
template instantiation 'std::map<_Kty,_Ty>' being compiled
with
[
_Kty=std::string,
_Ty=Function::MathFuncPtr
] 2 3322
Serengeti wrote: Hello, in my class I have a map that translates strings to pointers to some member functions. The code goes like this:
class F { typedef void (Function::*MathFuncPtr)(); std::map<std::string, MathFuncPtr> predefinedFunctions; // lots of other stuff void makeDictionary(){ predefinedFunctions["sin"]=&F::f_sin(); }
Replace
&F::f_sin()
with
&Function::f_sin
.. notice that (a) there are no parentheses and (b) the class name is not
'F', but 'Function'.
};
Code like this works all right in gcc, but causes a strange compile time error[*] in VC (from MSVC++ 2005 express beta). I'd be happy to know if it's my or VC's fault :)
TIA, Slawek
[*]:
c:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(239) : error C2065: '_Mycont' : undeclared identifier c:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(236) : while compiling class template member function 'const std::pair<_Ty1,_Ty2> &std::_Tree<_Traits>::const_iterator::operator *(void) const' with [ _Ty1=const std::string, _Ty2=Function::MathFuncPtr , _Traits=std::_Tmap_traits<std::string,Function::Ma thFuncPtr ,std::less<std::string>,std::allocator<std::pair<c onst std::string,Function::MathFuncPtr >>,false> ] c:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(395) : see reference to class template instantiation 'std::_Tree<_Traits>::const_iterator' being compiled with [ _Traits=std::_Tmap_traits<std::string,Function::Ma thFuncPtr ,std::less<std::string>,std::allocator<std::pair<c onst std::string,Function::MathFuncPtr >>,false> ] c:\Program Files\Microsoft Visual Studio 8\VC\include\map(164) : see reference to class template instantiation 'std::_Tree<_Traits>::iterator' being compiled with [ _Traits=std::_Tmap_traits<std::string,Function::Ma thFuncPtr ,std::less<std::string>,std::allocator<std::pair<c onst std::string,Function::MathFuncPtr >>,false> ] c:\Program Files\Microsoft Visual Studio 8\VC\include\map(163) : while compiling class template member function 'void (Function::* &std::map<_Kty,_Ty>::operator [](const std::basic_string<_Elem,_Traits,_Ax> &))(void)' with [ _Kty=std::string, _Ty=Function::MathFuncPtr, _Elem=char, _Traits=std::char_traits<char>, _Ax=std::allocator<char> ] d:\Documents and Settings\Serengeti\Moje dokumenty\My Projects\Derivatives\Derivatives\function.h(36) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled with [ _Kty=std::string, _Ty=Function::MathFuncPtr ]
--
Please remove capital As from my address when replying by mail
Victor Bazarov wrote: Replace
&F::f_sin()
with
&Function::f_sin
. notice that (a) there are no parentheses and (b) the class name is not 'F', but 'Function'.
well I've basically messed things up when preparing a code example for
the posting :) My real code looks exactly like your suggestion:
class Function {
typedef void (Function::*MathFuncPtr)();
std::map<std::string, MathFuncPtr> predefinedFunctions;
// lots of other stuff
void makeDictionary(){ predefinedFunctions["sin"]=&Function::f_sin; }
};
So I guess the problem is somewhere else.
thanks for answering,
Slawek This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Woodster |
last post by:
I have declared the following
std::map<std::string, std::string> myMap;
to pass myMap to functions should I be declaring functions as:
void function(std::map<std::string, std::string>);
...
|
by: Erik Wikström |
last post by:
First of all, forgive me if this is the wrong place to ask this question,
if it's a stupid question (it's my second week with C++), or if this is
answered some place else (I've searched but not...
|
by: Avery Fong |
last post by:
The following program will result in a compile error when building under Debug but will compile under Release. Why does is work under Release mode but not under Debug
This program is developed...
|
by: kamaraj80 |
last post by:
Hi
I am using the std:: map as following.
typedef struct _SeatRowCols
{
long nSeatRow;
unsigned char ucSeatLetter;
}SeatRowCols;
typedef struct _NetData
|
by: Evyn |
last post by:
Hi all,
I'm starting to fool around with STL and in particular std::map.
How do I iterate through one map and insert every pair in another map?
I have the following so far:
map<double,...
|
by: DevNull |
last post by:
Hi there everyone,
I'm creating a very simple immediate mode command interpreter.
The final purpose is to provide a pluggable control and command
console for a MUD server I have written.
The...
|
by: digz |
last post by:
Hi,
I am trying to write a program which has two threads one of them write
to a map , and the other one deletes entries based on a certain
criterion..
first I cannot get the delete portion to...
|
by: Matthias Pfeifer |
last post by:
Hi there,
a std::map is build from std::pair elements where for a pair p p.first
is called the key and p.second the value. Is there a way to keep the map
sorted by the values? Ie is there a...
|
by: mveygman |
last post by:
Hi,
I am writing code that is using std::map and having a bit of an issue
with its performance.
It appears that the std::map is significantly slower searching for an
element then a sequential...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |