C ++ 11添加C99限制说明符?如果不是,为什么不呢? [英] Does C++11 add the C99 restrict specifier? If not, why not?

查看:183
本文介绍了C ++ 11添加C99限制说明符?如果不是,为什么不呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

restrict 是一个C99特性,通过允许编译器对指针执行以前只有fortran的优化,得到了很多关注。这也是Microsoft最近宣布的关键是C ++ AMP规范的基础。

restrict is a C99 feature which is getting a lot of attention lately by allowing the compiler to perform "previously-fortran-only" optimizations to pointers. It's also the same keyword announced by Microsoft recently to be the underpinnings of the C++AMP specification.

这个关键字是否在FCD中?

Is that keyword actually in the FCD? If not, is there a specific reason it was omitted?

推荐答案

一个参数是C需要 restrict 超过C ++,因为许多操作都是通过指向原始类型的指针完成的,因此C代码比C ++具有更多别名问题。

One argument is that C needs restrict more than C++, because many operations are done with pointers to primitive types and therefore C code has more aliasing problems than C++.

别名规则说,指向不同类型的指针不能是别名,因此如果函数的参数具有不同的类类型,它们就不能重叠。

The aliasing rules say that pointers to different types cannot alias, so if the parameters to a function are of different class types they just cannot overlap.

在C ++中,我们还有 valarray 系列类,它们应该处理非原始类型数组允许别名。

In C++ we also have the valarray family of classes that are supposed to handle arrays of primitive types that are not allowed to alias. Not that it is used much...

添加另一种方式来解决一些别名问题,显然没有足够激发委员会。

Adding yet another way to resolve some aliasing problems, obviously didn't excite the committee enough.

这篇关于C ++ 11添加C99限制说明符?如果不是,为什么不呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆