Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Building Query using C++ Pin
T.RATHA KRISHNAN7-Jul-10 19:52
T.RATHA KRISHNAN7-Jul-10 19:52 
GeneralRe: Building Query using C++ Pin
«_Superman_»7-Jul-10 19:54
professional«_Superman_»7-Jul-10 19:54 
GeneralRe: Building Query using C++ Pin
T.RATHA KRISHNAN7-Jul-10 20:00
T.RATHA KRISHNAN7-Jul-10 20:00 
GeneralRe: Building Query using C++ Pin
«_Superman_»7-Jul-10 20:08
professional«_Superman_»7-Jul-10 20:08 
GeneralRe: Building Query using C++ Pin
T.RATHA KRISHNAN7-Jul-10 20:13
T.RATHA KRISHNAN7-Jul-10 20:13 
GeneralRe: Building Query using C++ Pin
«_Superman_»7-Jul-10 20:28
professional«_Superman_»7-Jul-10 20:28 
GeneralRe: Building Query using C++ Pin
T.RATHA KRISHNAN7-Jul-10 20:28
T.RATHA KRISHNAN7-Jul-10 20:28 
QuestionSpecial case of templates, pointers-to-members, inheritance - works in VC++ 2008, GCC 3.4.4, but fails in VC++ 2005 Pin
Kosta Cherry7-Jul-10 18:42
Kosta Cherry7-Jul-10 18:42 
Hi All,
I'm hitting my head against the wall third day about the following code:
//#define PointerToMember(B) B::*
#define PointerToMember(B)

template <bool A, typename B, typename C, C PointerToMember(B) D>
class One
{
	public:
	One() 	{};
};

template <typename B, typename C, C PointerToMember(B) D>
class One<true, B, C, D> : public One<false, B, C, D>
{
public:
	One<true, B, C, D>() : One<false, B, C, D>()	{	};
};

template <bool A, typename B>
struct Two
{
   template <typename C, C PointerToMember(B) D>
   class OneUsage : public One<A, B, C, D>   {   }; 
};


template <typename B>
struct Two<true, B> : public Two<false, B>
{
   template <typename C, C PointerToMember(B) D>
   class OneUsage : public One<true, B, C, D>   {  }; 

};

struct S {	int i;};

int main()
{
	//Two<true, S>::OneUsage<int, &S::i> two;
	Two<true, S>::OneUsage<int, 1> two;
	return 0;
}


With those two lines commented out, it compiles in all 3 compilers: GCC, VC++ 2008 and VC++ 2005. But, if instead of
//#define PointerToMember(B) B::*
#define PointerToMember(B)
...
//Two<true, S>::OneUsage<int, &S::i> two;
Two<true, S>::OneUsage<int, 1> two;


you will make it this:
#define PointerToMember(B) B::*
//#define PointerToMember(B)
...
Two<true, S>::OneUsage<int, &S::i> two;
//Two<true, S>::OneUsage<int, 1> two;


it still will compile in GCC and 2008, but will fail in 2005 with error:
error C2955: 'Two<A,B>::OneUsage' : use of class template requires template argument list
with
[
A=true,
B=S
]
list4.cpp(30) : see declaration of 'Two<A,B>::OneUsage'
with
[
A=true,
B=S
]
error C2133: 'two' : unknown size
error C2512: 'Two<A,B>::OneUsage' : no appropriate default constructor available
with
[
A=true,
B=S
]

Looks like VC++ 2005 compiler does not like usage of pointer-to-member type declaration when inheriting templates with partial specialization. Is it a bug of VC++ 2005, or I break some C++ standard, and other two compilers are just more forgiving?

This code was taken from much more complex one just to show exact problem. Code compiled by both VC++ 2008 and GCC works with no issue and as intended.

Thank you!
AnswerRe: Special case of templates, pointers-to-members, inheritance - works in VC++ 2008, GCC 3.4.4, but fails in VC++ 2005 Pin
Kosta Cherry7-Jul-10 19:04
Kosta Cherry7-Jul-10 19:04 
AnswerRe: Special case of templates, pointers-to-members, inheritance - works in VC++ 2008, GCC 3.4.4, but fails in VC++ 2005 [modified] Pin
Aescleal7-Jul-10 21:30
Aescleal7-Jul-10 21:30 
QuestionHow to Connect to DataBase using SQL in VC6 Pin
raju_shiva7-Jul-10 1:50
raju_shiva7-Jul-10 1:50 
AnswerRe: How to Connect to DataBase using SQL in VC6 Pin
Richard MacCutchan7-Jul-10 2:54
mveRichard MacCutchan7-Jul-10 2:54 
GeneralRe: How to Connect to DataBase using SQL in VC6 Pin
raju_shiva7-Jul-10 19:04
raju_shiva7-Jul-10 19:04 
GeneralRe: How to Connect to DataBase using SQL in VC6 Pin
Richard MacCutchan7-Jul-10 21:08
mveRichard MacCutchan7-Jul-10 21:08 
GeneralRe: How to Connect to DataBase using SQL in VC6 Pin
David Crow8-Jul-10 1:59
David Crow8-Jul-10 1:59 
QuestionRe: How to Connect to DataBase using SQL in VC6 Pin
David Crow7-Jul-10 3:43
David Crow7-Jul-10 3:43 
AnswerRe: How to Connect to DataBase using SQL in VC6 Pin
raju_shiva7-Jul-10 19:03
raju_shiva7-Jul-10 19:03 
GeneralRe: How to Connect to DataBase using SQL in VC6 Pin
David Crow8-Jul-10 2:02
David Crow8-Jul-10 2:02 
Questionswitching between views in MDI Pin
Sakhalean7-Jul-10 0:34
Sakhalean7-Jul-10 0:34 
AnswerRe: switching between views in MDI Pin
«_Superman_»7-Jul-10 0:40
professional«_Superman_»7-Jul-10 0:40 
GeneralRe: switching between views in MDI Pin
Sakhalean7-Jul-10 0:55
Sakhalean7-Jul-10 0:55 
GeneralRe: switching between views in MDI Pin
«_Superman_»7-Jul-10 0:58
professional«_Superman_»7-Jul-10 0:58 
GeneralRe: switching between views in MDI Pin
Sakhalean7-Jul-10 1:07
Sakhalean7-Jul-10 1:07 
AnswerRe: switching between views in MDI Pin
Niklas L7-Jul-10 1:48
Niklas L7-Jul-10 1:48 
GeneralRe: switching between views in MDI Pin
Sakhalean7-Jul-10 1:56
Sakhalean7-Jul-10 1:56 

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.