Hi,
following code will not compile with MS VC 7.1:
struct null_type;
template< bool B, typename T, typename E >
struct if_then_else;
template< typename T, typename E >
struct if_then_else< true, T, E >
{
typedef T result_type;
};
template< typename T, typename E >
struct if_then_else< false T, E >
{
typedef E result_type;
};
template< int N >
class A
{
private:
template< int M >
class X
{
typedef typename if_then_else< N <= M, A< M >, null_type >::result_type
result_type;
};
template< int M >
friend typename A< N >::X< M >::result_type;
//friend typename A::X< M >::result_type;
};
only such A< M > should become friends of A< N > if N <= M. but it doesn't
work :^(
why?
thx,
Oliver
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Oliver
|
12/4/2003 3:47:58 PM |
|
On Thu, 04 Dec 2003 10:47:58 -0500, Oliver Kowalke wrote:
> Hi,
>
> following code will not compile with MS VC 7.1:
(snip)
> only such A< M > should become friends of A< N > if N <= M. but it doesn't
> work :^(
> why?
IIRC, friends can never be templated. It would allow one to specialise the
template and as such gain friendship with the class through this backdoor.
I.O.W, it would create a hole in the type system.
HTH,
M4
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Martijn
|
12/5/2003 10:34:35 PM
|
|
Martijn Lievaart wrote:
> IIRC, friends can never be templated. It would allow one to specialise the
> template and as such gain friendship with the class through this backdoor.
> I.O.W, it would create a hole in the type system.
friends can be templates (so called friend-templates)
following code is legal
template< typename T >
class A
{};
class B
{
template< typename T >
friend class A;
};
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Oliver
|
12/6/2003 2:37:03 PM
|
|
|
2 Replies
114 Views
(page loaded in 0.065 seconds)
Similiar Articles: how to clear screen in unix - fn. similar to clrscr() in DOS ...... me > Google's usenet group search is your friend. ... I looked up the vc series terminals and the clear ... being, if you hard code either of these, it *won't work* for ... How to run Notepad and Paste from clipboard to it - comp.lang ...... RUN NOTEPAD.EXE KEYBOARD K_CTRL_V But this doesn't work. ... think it will be better for them to open in MS Word ... While googling for your query I found one sample for vb... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... OpenGL SDK for windows - comp.graphics.api.opengl... graphic > card driver and Visual C has all you need for it. >=20 all except opengl > 1.1. ... complaining to you that it doesn't work on ... Kit Documentation, Sample Code ... 64 bit integer - comp.lang.c++.moderated... If the compiler complains, it isn't conform. >>>Plus 17.4.3.1.2 allows them (MS ... > I think VC will do this also with some ... of code out there which unwittingly doesn't work ... Environmental variables to point at libraries with Modelsim ...... Has anyone got anything similar to work? Yes, I haven't had any ... If that doesn't give you the right value, then you ... Now I can (at last) have a unified project template! ptr versus const ptr& - comp.lang.c++.moderated> Based on my work it seems that boths ways ... No need to make this one a friend, it doesn't use any ... class my_pointer; my_pointer(T* p) : ptr(p) {} template<typename U ... Sampling: What Nyquist Didn't Say, and What to Do About It - comp ...... in the PDF doesn't ... 27.xxx Hz sample rate. Using available crystals. I also used a 7-bit single-slope ADC, which I didn't ... if you don't want to use TeX or its friends ... DSP Job opening in Sacramento, CA - comp.dsp... up for a football game, but they won't ... Come to think of it, this might work anywhere in the world and I just wouldn't ... of federal cufflink."--Fritsche Middle School ... YASM - comp.lang.asm.x86I am afraid not, YASM doesn't handle debugging ... the 32-bit version of CodeView used for VC ... no, I don't belong to the "club" - can't afford it, y'know, a student, working ... VMware ESX Deploy Template Wizard and MS SYSPREP - Guest ...... is running doesn’t have ... ESX Deploy Template Wizard and MS ... couldn’t figure out why my x64 cust. wizards were not working. I had to do a clean install of VC 2.5u3 ... No effect of "define _CRT_SECURE_NO_DEPRECATE 1"... to why this doesn't work as documented in the help. Thanks. Sample ... in stdafx.h doesn't seem to work for me. I'd be grateful for ther ideas. MS ... Studio 8\VC ... 7/16/2012 9:19:24 AM
|