🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3722

Template issue in MS VC++ 4.0, Non Standard?

#3722
From: Peter J Brock
Date: Mon, 18 Mar 1996 21:59
72 lines
2219 bytes
The following code illustrates a bug in the implementation of
templates in MS Visual C++ 4.0.

//___________begin code sample__________________________
// test.cpp

template <class T>
class VeryTesting
{     
	public: 
		VeryTesting();
		T& operator()();
		T 	m_T;
};

template <class T>
inline
VeryTesting<T>::VeryTesting () 
{
}

template <class T>
inline T& 
VeryTesting<T>::operator ()()
{
	return m_T;
}

//  Uncomment this block of code and it all works!
// template VeryTesting<double>;

class A
{
public :
	A(){}
	~A(){}

	VeryTesting<double>& test(VeryTesting<double>& fdTest)
	{
		fdTest() = 5.0; //error C2064: term does not evaluate to a function
		return fdTest;
	}
};

main()
{
	VeryTesting<double> f;
	f() = 5.0;
	A aObject;
	aObject.test(f);
}
//___________end code sample___________________________


The problem is that VeryTesting<double> is not instantiated correctly
by the MS Visual C++ 4.0 compiler. This results in the error message
that says function fdTest() does not evaluate to a function.

The code compiles under Borland 4.5.

So leads one to the question of how will compilers be vetted against a
standard when it comes?

Cheers,
Peter J Brock	http://www.magna.com.au/~peter

---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <4ijj74$mp@kettle.magna.com.au>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back

Show Full Headers
Complete Article Headers
From: peter@magna.com.au (Peter J Brock)
Message-ID: <4ijj74$mp@kettle.magna.com.au>
X-Original-Date: Mon, 18 Mar 1996 12:02:09 GMT
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 18 Mar 96 21:59:15 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Template issue in MS VC++ 4.0, Non Standard?
Organization: Me
Reply-To: peter@magna.com.au
X-Newsreader: Forte Free Agent v0.55
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBEAgUBMU3cyeEDnX0m9pzZAQFioQF4/y4bn1YKTIstQqzL5TIllG2NWI8FJQWZ
 mO/2XXH1pQWAQMKqbtuRe3+69GXOGVk=
 =DIZY