算法实现 [英] algorith implementation

查看:89
本文介绍了算法实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

template< class OutputIterator,class Size,class T>

void fill_n(OutputIterator first,size n,const T& value)

{

while(n-- 0)* first ++ = value;

}


如果Size必须可转换为整数类型,这不是

实现不包括将枚举值作为第二个

参数传递?枚举值可以转换为整数类型,因此

实现与规范不匹配。


发布通过Usenet.com Premium Usenet新闻组服务
--------------------------------------------- -------------

**速度**保留**完成**匿名**

------- -------------------------------------------------- -
http://www.usenet.com

template <class OutputIterator, class Size, class T>
void fill_n (OutputIterator first, Size n, const T& value)
{
while (n-- 0) *first++ = value;
}

If Size must be convertible to an integral type is this not an
implementation that excludes passing an enum value as the second
parameter? An enum value is convertible to an integral type so the
implementation does not match the specification.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

推荐答案

Fraser Ross写道:
Fraser Ross wrote:

template< class OutputIterator,class Size,class T>

void fill_n(OutputIterator first,size n,const T& value)

{

while(n-- 0)* first ++ = value;

}


如果Size必须可以转换为整数类型,这不是

实现,它排除了将枚举值作为第二个传递

参数?枚举值可以转换为整数类型,因此

实现与规范不匹配。
template <class OutputIterator, class Size, class T>
void fill_n (OutputIterator first, Size n, const T& value)
{
while (n-- 0) *first++ = value;
}

If Size must be convertible to an integral type is this not an
implementation that excludes passing an enum value as the second
parameter? An enum value is convertible to an integral type so the
implementation does not match the specification.



正确。你在哪里找到这个?更好的方法是制作




void fill_n(首先是OutputIterator,大小为n_arg,const T& value)

{

size_t n = n_arg; ...


,可能。


V

-

请在通过电子邮件回复时删除资本''A'

我没有回复最热门的回复,请不要问

Correct. Where did you find this one? A better way would be to make
it

void fill_n (OutputIterator first, Size n_arg, const T& value)
{
size_t n = n_arg; ...

, probably.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


Victor Bazarov写道:
Victor Bazarov wrote:

正确。你在哪里找到这个?
Correct. Where did you find this one?



我在gcc的STL中发现了同样的问题。确实sgi'的STL文档

定义了尺寸必须是整数类型的要求。


Jens

I found the same issue in gcc''s STL. Indeed sgi''s STL documentation
defines the requirement to be that Size must be an integral type.

Jens

< br>

Jens Theisen写道:
Jens Theisen wrote:

Victor Bazarov写道:
Victor Bazarov wrote:

>正确。你在哪里找到这个?
>Correct. Where did you find this one?



我在gcc的STL中发现了同样的问题。事实上,sgi'的STL文档

定义了Size必须是一个整数类型的要求。


I found the same issue in gcc''s STL. Indeed sgi''s STL documentation
defines the requirement to be that Size must be an integral type.



该标准现已存在(自1997年以来),因此任何C ++

标准库实现都不会使用本地OP暗示变量是

无法使用枚举。


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要问

The requirement now exists in the Standard (since 1997), so any C++
standard library implementation that doesn''t use a local variable is
not going to work with enums, as the OP hinted.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


这篇关于算法实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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