为什么?为什么?为什么?模板实施不足 [英] Why? Why? Why? insufficient template implementation
问题描述
我只是想知道。经过这么多年的工作后,为什么微软还没有看到完全适合完全实现C ++标准的模板部分呢?/ >
许多其他供应商,无论是免费商用还是商业用户,或者至少已经非常接近这样做了。我在
纯C ++中编写代码,我经常不得不在我的
代码中使用它来使它在Visual C ++中工作。
这是一个我的意思的简单例子:
#ifdef _WIN32
模板< typename T,
模板< typename元素,
typename Alloc = std :: allocator< ELEM> >
class Container = std :: deque>
class Stack
{
Container< T,的std ::分配器< T> > m_elems;
#else
模板< typename T,
模板< typename元素,
typename = std :: allocator< ELEM> >
class Container = std :: deque>
class Stack
{
Container< T> m_elems;
#endif
请注意_WIN32代码下我需要如何命名Alloc而不是
而不仅仅是设置第二个类型名称默认情况下,以及
课程,VC ++忽略了我必须的默认值
明确定义元素类型的容器和
分配器类型。这很麻烦。
那么,有没有人知道为什么微软没有聘请
模板专家来正确实施模板?我想b $ b假设他们只是想杀死C ++以及他们发明的一切。呃,好吧。毕竟它将是一个C#
世界。 Ugggg。
Thomas J. Clancy
对不起,代码示例应如下所示
#ifdef _WIN32
模板< typename T,
模板< typename元素,
typename Alloc =的std ::分配器<组件> >
class Container = std :: deque>
class Stack
{
Container< T,的std ::分配器< T> > m_elems;
#else
模板< typename T,
模板< typename元素,
typename = std :: allocator< Element> >
class Container = std :: deque>
class Stack
{
Container< T> m_elems;
#endif
-----原帖-----
我是就是想。经过所有这些年来在Visual C ++上工作
之后,为什么微软还没有看到完全实现C ++标准的模板部分,而其他供应商(包括免费和商业版)都是如此。有,或者至少已经非常接近这样做了。我用纯粹的C ++编写代码,我经常不得不在我的代码中找到它才能使它在Visual C ++中工作。
这是一个简单的例子我的意思是:
#ifdef _WIN32
模板< typename T,
模板< typename元素,
typename Alloc = std :: allocator< ELEM> >
类Container = std :: deque>
类Stack
{
容器< T,std :: allocator< T> > m_elems;
#else
模板< typename T,
模板< typename元素,
typename = std :: allocator< ELEM> >
类Container = std :: deque>
类Stack
{
容器< T> m_elems;
#endif
请注意_WIN32代码下如何命名Alloc
只需设置第二个typename'的默认值,然后选择
在正文中,VC ++忽略了我必须用元素类型和
分配器类型显式定义Container的默认值。这很麻烦。
那么,有没有人知道为什么微软没有聘请
模板专家来正确实施模板?我认为他们只是试图杀死C ++以及他们没有发明的一切。呃,好吧。毕竟它将是一个C#
世界。 Ugggg。
Thomas J. Clancy
。
Thomas J. Clancy写道:我只是想知道。经过所有这些年的Visual C ++工作,为什么微软还没有看到完全实现C ++标准的模板部分呢?
许多其他供应商,包括免费和商业,有,或至少已经非常接近这样做。
实际上,只有一家供应商(Comeau)甚至声称完全实现了C ++标准。与早期版本的VC ++相比,VC7.1向前迈出了一大步,未来的版本将更好。
我用纯C ++编写代码为了让它在Visual C ++中工作,我经常不得不从我的代码中解脱出来。
当然你不 - 你选择。在这里给出的例子中,
" MSVC"版本也是100%合法的C ++代码,您的其他编译器可能会接受
。为什么不简单地在任何地方使用该表单,而不是使用#ifdefs使你的代码混乱?
所以,有没有人知道为什么微软没有雇用一个
模板专家正确实现模板?我认为他们只是试图杀死C ++以及他们没有发明的一切。呃,好吧。毕竟它将是一个C#
世界。 Ugggg。
实际上,微软正投入大量资源来支持和开发C ++。然而,事实是,完全支持
模板非常困难,直到最近,并没有成为客户优先考虑的事情。向后兼容性和代码生成质量对MS的主要客户群来说更为重要。请放心:微软对C ++的承诺是非常强大的。 VC7.1并不完美,但
这是对VC6的巨大改进。
-cd
-----原始消息-----
Thomas J. Clancy写道:我只是想知道。经过所有这些年在Visual C ++上工作
之后,为什么微软还没有看到适合完全实现C ++标准的模板部分当
这么多其他供应商,包括免费和商业,有,或者
至少已经非常接近这样做。
实际上,只有一个供应商(Comeau)甚至声称
已经完全实现了C ++标准。与早期版本的VC ++相比,VC7.1是一个巨大的步骤
,未来版本将更好地为
。
最新版本的GCC编译大部分标准
模板的东西都没问题,这就是为什么我问
左右VC ++。当我使用
GCC / G ++编写Linux或Unix代码然后将其移植到Windows时,我经常需要使用VC ++ 7.1来ifdef,
。这就是提示这些
问题的原因。
我用纯粹的C ++编写代码我常常有如果只是为了让它在Visual C ++中运行,那么我就可以了解它。
当然你不 - 你选择了。在示例中,您
在这里给出MSVC和MSVC。版本也是100%合法的C ++代码,你的
其他编译器可能会接受。为什么不简单地在任何地方使用该表单,
而不是用#ifdefs来混淆你的代码?
见上面的评论。我经常使用GCC基于标准
编写。移植时我会注意到问题和ifdef。
是的,我可以轻松地降级我的代码以符合VC ++
7.1然后我可以取消ifdef。所以你在这里是正确的,但是,它仍然是一个痛苦的屁股必须
看到关于完全有效和标准的错误信息 -
符合代码。
那么,有没有人知道为什么微软没有聘请
模板专家正确实施模板?我认为他们只是试图杀死C ++以及他们没有发明的一切。呃,好吧。毕竟,这将是一个
C#世界。 Ugggg。
实际上,微软正投入大量资源来支持和开发C ++,以支持和支持
。然而,问题的事实是,
完全支持模板是非常困难的,直到最近非常b $ b,并不是客户的优先事项。向后兼容性和代码 -
生成质量对于MS的主要客户群来说更为重要。休息
放心:微软对C ++的承诺非常强大。 VC7.1
并不完美,但是它比VC6有了很大的改进。
我同意VC6的巨大改进。是的,
完整的模板支持很难,但我相信这对于没有实现某些东西的有效借口来说,
尤其是微软拥有的资源处理它的价格。
我相信你对客户的优先权是正确的。
大多数人都不喜欢无论如何,我真的很了解模板而且
可能没有太多关于纯标准的要求
在学术领域以外的一致性,但我仍然不会
发现这是一个充分的理由,不开发符合标准的产品
,特别是因为
标准现在已经五年了。
虽然你声称微软致力于C ++,但是我觉得很难相信,特别是
现在使用C#和他们已添加的所有gastly扩展
C ++。如果他们的标准合规性似乎是支持b $ b b / b。现在我说好像是。您的评估中可能
是正确的。当你没有承诺一个
环境/一个编译器并且必须创建可移植代码时,它只会有点尴尬
令人沮丧
和找出所有
编译器之间的共同点。 :-)
Tom
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<typename T,
template<typename Element,
typename Alloc = std::allocator<ELEM> >
class Container = std::deque >
class Stack
{
Container<T,std::allocator<T> > m_elems;
#else
template<typename T,
template<typename 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解决方案Sorry, the code sample should read as follows
#ifdef _WIN32
template<typename T,
template<typename Element,
typename Alloc = std::allocator<Element> >
class Container = std::deque >
class Stack
{
Container<T,std::allocator<T> > m_elems;
#else
template<typename T,
template<typename 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<typename T,
template<typename Element,
typename Alloc = std::allocator<ELEM> >
class Container = std::deque >
class Stack
{
Container<T,std::allocator<T> > m_elems;
#else
template<typename T,
template<typename 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
.
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
-----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
这篇关于为什么?为什么?为什么?模板实施不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!