473,770 Members | 4,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why? Why? Why? insufficient template implementation


I was just wondering. After all these years of working on
Visual C++, why hasn't Microsoft yet seen fit to fully
implement the template portion of the C++ standard when so
many other vendors, both free and commercial, have, or at
least have come very close to doing so. I write code in
pure C++ and I so often have to ifdef the heck out of my
code just to get it to work in Visual C++.

Here is a simple example of what I mean:

#ifdef _WIN32
template<typena me T,
template<typena me Element,
typename Alloc = std::allocator< ELEM> >
class Container = std::deque >
class Stack
{
Container<T,std ::allocator<T> > m_elems;
#else

template<typena me T,
template<typena me Element,
typename = std::allocator< ELEM> >
class Container = std::deque >
class Stack
{
Container<T> m_elems;
#endif

Note how under the _WIN32 code I need to name Alloc rather
than just setting the second typename's default, and of
course in the body, VC++ ignores the default an I have to
explicitly define Container with the element type and the
allocator type. This is just messy.

So, does anyone know why Microsoft just hasn't hired a
template expert to implement templates correctly? I
suppose that they are just trying to kill C++ as well as
everything not invented by them. Ah well. It'll be a C#
world after all. Ugggg.

Thomas J. Clancy
Nov 16 '05 #1
13 1504
Sorry, the code sample should read as follows

#ifdef _WIN32
template<typena me T,
template<typena me Element,
typename Alloc = std::allocator< Element> >
class Container = std::deque >
class Stack
{
Container<T,std ::allocator<T> > m_elems;
#else

template<typena me T,
template<typena me Element,
typename = std::allocator< Element> >
class Container = std::deque >
class Stack
{
Container<T> m_elems;
#endif

-----Original Message-----

I was just wondering. After all these years of working onVisual C++, why hasn't Microsoft yet seen fit to fully
implement the template portion of the C++ standard when somany other vendors, both free and commercial, have, or at
least have come very close to doing so. I write code in
pure C++ and I so often have to ifdef the heck out of my
code just to get it to work in Visual C++.

Here is a simple example of what I mean:

#ifdef _WIN32
template<typen ame T,
template<typena me Element,
typename Alloc = std::allocator< ELEM> >
class Container = std::deque >
class Stack
{
Container<T,std ::allocator<T> > m_elems;
#else

template<typen ame T,
template<typena me Element,
typename = std::allocator< ELEM> >
class Container = std::deque >
class Stack
{
Container<T> m_elems;
#endif

Note how under the _WIN32 code I need to name Alloc ratherthan just setting the second typename's default, and of
course in the body, VC++ ignores the default an I have to
explicitly define Container with the element type and the
allocator type. This is just messy.

So, does anyone know why Microsoft just hasn't hired a
template expert to implement templates correctly? I
suppose that they are just trying to kill C++ as well as
everything not invented by them. Ah well. It'll be a C#
world after all. Ugggg.

Thomas J. Clancy
.

Nov 16 '05 #2
Thomas J. Clancy wrote:
I was just wondering. After all these years of working on
Visual C++, why hasn't Microsoft yet seen fit to fully
implement the template portion of the C++ standard when so
many other vendors, both free and commercial, have, or at
least have come very close to doing so.
Actually, only a single vendor (Comeau) even claims to have fully
implemented the C++ standard. VC7.1 is a huge step forward compared to
earlier versions of VC++, and future version will be better still.
I write code in
pure C++ and I so often have to ifdef the heck out of my
code just to get it to work in Visual C++.
Of course you dont - you choose to. In the example you give here, the
"MSVC" version is also 100% legal C++ code that your other compilers would
likely accept. Why not simply use that form everywhere, rather than
cluttering your code with #ifdefs?
So, does anyone know why Microsoft just hasn't hired a
template expert to implement templates correctly? I
suppose that they are just trying to kill C++ as well as
everything not invented by them. Ah well. It'll be a C#
world after all. Ugggg.


Actually, Microsoft is devoting considerable resources to supporting and
developing C++. The fact of the matter is, however, that fully supporting
templates is exremently difficult, and up until very recently, hasn't been a
customer priority. Backwards compatibility and code-generation quality are
much more important to MS's main customer base. Rest assured: the
commitment to C++ at Microsoft is very strong. VC7.1 isn't perfect, but
it's a huge improvement over VC6.

-cd

Nov 16 '05 #3

-----Original Message-----
Thomas J. Clancy wrote:
I was just wondering. After all these years of working on Visual C++, why hasn't Microsoft yet seen fit to fully
implement the template portion of the C++ standard when so many other vendors, both free and commercial, have, or at least have come very close to doing so.
Actually, only a single vendor (Comeau) even claims to

have fullyimplemented the C++ standard. VC7.1 is a huge step forward compared toearlier versions of VC++, and future version will be better still.
The latest versions of GCC compile most of the standard
template stuff with little problem, which is why I asked
about VC++. When I write code for Linux or Unix using
GCC/G++ and then port it to windows I often have to ifdef,
even now with VC++ 7.1. This is what prompted these
questions.
I write code in
pure C++ and I so often have to ifdef the heck out of my
code just to get it to work in Visual C++.


Of course you dont - you choose to. In the example you

give here, the"MSVC" version is also 100% legal C++ code that your other compilers wouldlikely accept. Why not simply use that form everywhere, rather thancluttering your code with #ifdefs?

See my above comment. I often write based on the standard
using GCC. When porting I notice the problems and ifdef.
Yes, I could easily downgrade my code to conform to VC++
7.1 and then I could do away with ifdefs. So you are
correct here, but still, its a pain in the butt having to
see error messages regarding completely valid and standard-
conforming code.
So, does anyone know why Microsoft just hasn't hired a
template expert to implement templates correctly? I
suppose that they are just trying to kill C++ as well as
everything not invented by them. Ah well. It'll be a C# world after all. Ugggg.


Actually, Microsoft is devoting considerable resources to

supporting anddeveloping C++. The fact of the matter is, however, that fully supportingtemplates is exremently difficult, and up until very recently, hasn't been acustomer priority. Backwards compatibility and code- generation quality aremuch more important to MS's main customer base. Rest assured: thecommitment to C++ at Microsoft is very strong. VC7.1 isn't perfect, butit's a huge improvement over VC6.


I do agree about the huge improvements over VC6. And yes,
full template support is difficult, but I believe this to
not be a valid excuse for not implementing something,
especially with the resources that microsoft has at its
disposal.

I believe you are correct about the customer priority.
Most people don't really understand templates anyway and
there probably isn't much of a call for pure standards
conformance outside the academic realm, but I still don't
find this an adequate excuse for not developing a product
that conforms to the standard, especially given that the
standard is now five years old.

Although you claim that microsoft is committed to C++, for
some reason I find that difficult to believe, especially
now with C# and all the gastly extensions they've added to
C++. If anything their standards compliance seems to be
on the back burner. Now I said "seems to be." You might
be correct in your assessment. It just gets a little
frustrating when you're not committed to one
environment/one compiler and have to create portable code
and figure out the common denominator between all
compilers. :-)

Tom
Nov 16 '05 #4
Thomas J. Clancy wrote:
Although you claim that microsoft is committed to C++, for
some reason I find that difficult to believe, especially
now with C# and all the gastly extensions they've added to
C++. If anything their standards compliance seems to be
on the back burner. Now I said "seems to be." You might
be correct in your assessment. It just gets a little
frustrating when you're not committed to one
environment/one compiler and have to create portable code
and figure out the common denominator between all
compilers. :-)


No denying that - it is frustrating trying to find the secret sauce that
makes your code compile across many compliers. If you haven't used them,
take a look at the Boost libraries (www.boost.org) which provide many
powerful features and which support many compilers (and, in many cases, are
riddled with annoying #ifdefs to deal with each compiler's vagueries).

Just wait for Whidbey. It think you'll be impressed with the commitment
that MS does have to C++.

-cd\
Nov 16 '05 #5
-----Original Message-----
Thomas J. Clancy wrote:
Although you claim that microsoft is committed to C++, for some reason I find that difficult to believe, especially
now with C# and all the gastly extensions they've added to C++. If anything their standards compliance seems to be
on the back burner. Now I said "seems to be." You might be correct in your assessment. It just gets a little
frustrating when you're not committed to one
environment/one compiler and have to create portable code and figure out the common denominator between all
compilers. :-)
No denying that - it is frustrating trying to find the

secret sauce thatmakes your code compile across many compliers. If you haven't used them,take a look at the Boost libraries (www.boost.org) which provide manypowerful features and which support many compilers (and, in many cases, areriddled with annoying #ifdefs to deal with each compiler's vagueries).
Yes, I use boost all the time. I really like it for many
reasons. :-)
Just wait for Whidbey. It think you'll be impressed with the commitmentthat MS does have to C++.

-cd\


What is Whidbey?

Nov 16 '05 #6
>> Just wait for Whidbey. It think you'll be impressed with the
commitment that MS does have to C++.


What is Whidbey?


The next version of Visual Studio. There used to be a "Visual Studio
Roadmap" posted on the MSDN site - I'm sure it's still around somewhere, but
I couldn't find a link to it with a few minutes hunting. The roadmap
outline some of the things that will be coming in Visual Studio "Whidbey".

-cd
Nov 16 '05 #7
Carl Daniel [VC++ MVP] wrote:
Just wait for Whidbey. It think you'll be impressed with the
commitment that MS does have to C++.


What is Whidbey?


The next version of Visual Studio. There used to be a "Visual Studio
Roadmap"


Here it is:

http://msdn.microsoft.com/vstudio/pr...o/roadmap.aspx

-cd
Nov 16 '05 #8

I completely and wholeheartedly agree! Thanks for backing
me up here. Still, perhaps this new Whidbey will be
better. I have some surefire tests... just try to use
loki, for example. :-)

Tom

-----Original Message-----
"Carl Daniel [VC++ MVP]" <cp******@nospa m.mvps.org> wrote:
[...]
Just wait for Whidbey. It think you'll be impressed with the commitment that MS does have to C++.
I had a look at the roadmap before.
For C++ in Whidbey it talks about .NET, world-class
libraries as MFC, POGO and such. Not a single word
about C++ standards conformance.

Shall I say it again?
We do write software that runs on almost half a
dozen platforms, herding half a dozen compilers
and compiler versions. The three things we are
most interested in are standard conformance,
standard conformance, and standard conformance.
C# compatibility, the .NET platform, MFC and
such don't hurt, as long as we can turn that
stuff off and the VC team doesn't spend much
time with implementing it. Everything that ought
to work on all platforms, but doesn't work on
one, is a PITA. Yes, with VC71 we even start to
find bugs in our other compilers. (With VC6 we
never got that far). But still, the more I get
into more complicated template stuff, the more I
encounter bugs and limitations. Fix these issues,
so I can write and use advanced code and libraries
using VC. Then do all the whistles and bells.
(Heck, I know how to make my IDE crash immediately.
But that's no big deal, I can easily work around
that without hurting the other platforms. But if
the compiler dies, that takes a lot of time and
clutters the code.)
-cd\


Schobi

--
Sp******@gmx.d e is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough

not to?" Beth Orton
.

Nov 16 '05 #9
Loki was on the list of libraries we verified the 7.1 compiler with. We
shipped with no know issues in building Loki code.

Ronald Laeremans
Visual C++ team

"Thomas J. Clancy" <tc*****@netspo ke.com> wrote in message
news:0b******** *************** *****@phx.gbl.. .

I completely and wholeheartedly agree! Thanks for backing
me up here. Still, perhaps this new Whidbey will be
better. I have some surefire tests... just try to use
loki, for example. :-)

Tom

-----Original Message-----
"Carl Daniel [VC++ MVP]" <cp******@nospa m.mvps.org> wrote:
[...]
Just wait for Whidbey. It think you'll be impressed with the commitment that MS does have to C++.


I had a look at the roadmap before.
For C++ in Whidbey it talks about .NET, world-class
libraries as MFC, POGO and such. Not a single word
about C++ standards conformance.

Shall I say it again?
We do write software that runs on almost half a
dozen platforms, herding half a dozen compilers
and compiler versions. The three things we are
most interested in are standard conformance,
standard conformance, and standard conformance.
C# compatibility, the .NET platform, MFC and
such don't hurt, as long as we can turn that
stuff off and the VC team doesn't spend much
time with implementing it. Everything that ought
to work on all platforms, but doesn't work on
one, is a PITA. Yes, with VC71 we even start to
find bugs in our other compilers. (With VC6 we
never got that far). But still, the more I get
into more complicated template stuff, the more I
encounter bugs and limitations. Fix these issues,
so I can write and use advanced code and libraries
using VC. Then do all the whistles and bells.
(Heck, I know how to make my IDE crash immediately.
But that's no big deal, I can easily work around
that without hurting the other platforms. But if
the compiler dies, that takes a lot of time and
clutters the code.)
-cd\


Schobi

--
Sp******@gmx.d e is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough

not to?"
Beth Orton
.

Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1644
by: Chris F Clark | last post by:
In our C++ project we have some internal bug reporting macros that we use to get useful information when the program does something unexpected. Essentially at the point of the error, we invoke an internal interactive debugger that knows the classes within our system and allow us to walk around the objects that exist at the time of the fault. It mostly works fairly well. That catch being that we have to hand implement some of the code...
1
2360
by: mathieu | last post by:
Hello there, I am playing around with template metaprograming: I am trying to redefines my own types. But I am facing a small issue, where I cannot describe the whole implementation in one single class. Instead I have to separate implementation for binary and ascii in two different classes as I don't know how to use the traits technique for constructors. Any pointers very welcome !
9
1831
by: Christof Warlich | last post by:
Hi, consider this: template<typename Tclass X { public: void doSomething(T t); }; int main(void) { X<intx;
7
2182
by: woessner | last post by:
Hi all, I whipped up a quick class to represent a matrix for use with LAPACK. It's a template class so it can support the 4 data types supported by LAPACK (single/double x complex/real). I added a conversion operator to automatically convert the object to a pointer of the appropriate type. This makes using LAPACK in C++ a lot easier. Unfortunately, it does not work well for the complex data types. The reason is that LAPACK (or,...
2
2469
by: David O | last post by:
I am using the CRTP (Curiously Recurring Template Pattern) to provide a set of low-level functions customizable by environment. Using CRTP ensures that all the function have the same signatures, which becomes important as the interfaces grow, especially where hardware interfaces are involved. For example: // Feature set for the environment... template< class Implementation >
0
1354
by: anto.anish | last post by:
Hi , Since, i did not want to write all instantiations in Source file of all template methods for various different datatypes that my client might use, Instead, i choose to write implementation of template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
0
1993
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
1
2779
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
5
2383
by: (2b|!2b)==? | last post by:
I would like to know if I can specialize only a specific method for a class template. Is the (specialization) code below valid? template <typename T1, typename T2> class MyClass { public:
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.