Click here to Skip to main content
15,896,207 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
ganesa moorthy11-Mar-08 3:28
ganesa moorthy11-Mar-08 3:28 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
ptr_Electron11-Mar-08 3:49
ptr_Electron11-Mar-08 3:49 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
CPallini11-Mar-08 3:32
mveCPallini11-Mar-08 3:32 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
ptr_Electron11-Mar-08 3:48
ptr_Electron11-Mar-08 3:48 
QuestionRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
CPallini11-Mar-08 3:53
mveCPallini11-Mar-08 3:53 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
ptr_Electron11-Mar-08 3:57
ptr_Electron11-Mar-08 3:57 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
CPallini11-Mar-08 4:01
mveCPallini11-Mar-08 4:01 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
Rajkumar R11-Mar-08 4:01
Rajkumar R11-Mar-08 4:01 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
Randor 11-Mar-08 4:08
professional Randor 11-Mar-08 4:08 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
ptr_Electron11-Mar-08 4:40
ptr_Electron11-Mar-08 4:40 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
Randor 11-Mar-08 5:57
professional Randor 11-Mar-08 5:57 
GeneralRe: m_pAnimate =new CStatusbarAnimate; cause crash only from thread Pin
ptr_Electron11-Mar-08 22:58
ptr_Electron11-Mar-08 22:58 
Generalprimary key field Pin
Try11-Mar-08 2:59
Try11-Mar-08 2:59 
GeneralRe: primary key field Pin
Randor 11-Mar-08 7:29
professional Randor 11-Mar-08 7:29 
QuestionRe: primary key field Pin
David Crow11-Mar-08 10:13
David Crow11-Mar-08 10:13 
GeneralRe: primary key field Pin
Randor 11-Mar-08 11:37
professional Randor 11-Mar-08 11:37 
GeneralRe: primary key field Pin
David Crow12-Mar-08 2:31
David Crow12-Mar-08 2:31 
GeneralNetworking Pin
mirtu11-Mar-08 2:47
mirtu11-Mar-08 2:47 
QuestionRe: Networking Pin
David Crow12-Mar-08 2:52
David Crow12-Mar-08 2:52 
GeneralRe: Networking Pin
mirtu13-Mar-08 21:38
mirtu13-Mar-08 21:38 
GeneralRe: Networking Pin
David Crow14-Mar-08 2:38
David Crow14-Mar-08 2:38 
GeneralRe: Networking Pin
mirtu14-Mar-08 18:29
mirtu14-Mar-08 18:29 
GeneralRe: Networking Pin
David Crow15-Mar-08 4:23
David Crow15-Mar-08 4:23 
Generaltemplate function argument deduce Pin
George_George11-Mar-08 2:38
George_George11-Mar-08 2:38 
Hello everyone,


Why in the following code segment (along with Bjarne's comments), function get_new can not deduce template parameter type to be int by its return value assignment to int * p1, and deduce T* is int*, and so T is int (e.g. as we did for function release in the same sample below)?

class Memory { // some Allocator
public:
template <class T> T * get _new ();
template <class T > void release (T&);
/ / ...
};

template <class Allocator> void f (Allocator &m )
{
int * p1 = m.get _ new <int>(); // syntax error: int after lessthan
operator
int * p2 = m.template get _ new <int>(); // explicit qualification
/ / ...
m.release (p1); // template argument deduced: no explicit qualification needed
m.release (p2 );
}


Explicit qualification of get _new() is necessary because its template parameter cannot be deduced. In this case, the t e m p l a t e prefix must be used to inform the compiler (and the human reader) that get _new is a member template so that explicit qualification with the desired type of element is possible. Without the qualification with template , we would get a syntax error because the < would be assumed to be a less than operator. The need for qualification with template is rare because most template parameters are deduced.


thanks in advance,
George
GeneralRe: template function argument deduce Pin
CPallini11-Mar-08 3:06
mveCPallini11-Mar-08 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.