🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Peter J Brock Mon, 18 Mar 1996 21:59
Template issue in MS VC++ 4.0, Non Standard?
#3722
Author: 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                             ]
Re: Template issue in MS VC++ 4.0, Non Standard?
#3731
Author: Jason Merrill
Date: Tue, 19 Mar 1996 04:55
21 lines
1539 bytes
>>>>> Peter J Brock <peter@magna.com.au> writes:

> The following code illustrates a bug in the implementation of
> templates in MS Visual C++ 4.0.

Yup, looks that way.

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

With testsuites, same as with any other language.  There are already
several commercial C++ testsuite vendors.

Jason
---
[ 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                             ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads