当前注册人数423093人 邮箱: 密码: 注册新用户 忘记密码
首页 C/C++/MFC C# ASP.NET VB.NET MATLAB Android   站内搜索 下载代码说明/积分规则
为什么要注册?

1. 可以直接免费从本站下载代码,防止邮件发送不到您的邮箱,或登录不了国外网站

2. 可以设定关键字,当有您关心的代码收录时,邮件通知您

3. 对这里的代码进行评分和评论

4. 可以和大家一起分享你的源代码,得到更多的建议

40万国外源码搜索
200万国内源码搜索
相关源代码

Yield Return Iterator for Native C++ Using Fibers

在C++ Native中实现C#的Yield return功能(fiber)

2008年03月04日
C++, VC6, VC7, VC7.1, VC8.0, Windows, TabletPC, Vista, VS, MFC, VS.NET2002, VS.NET2003, VS2005, VS6, Dev
微软的.NET中C#2.0实现了yield return功能,这个程序教你如何在Native C++中实现它。C#在foreach中使用,C++在for里调用。这样就使得迭代器的功能更加简单,使用的时候也很方便。
相关知识

相关代码:

int SomeCollection::Enumerate()
{
    for (int i=0; i<4; i++)
        yield_return(rand());
    return rand();
}

需要自定义类:

template <class T, class R>
void Enumerator::Return(const R &value)
{
    Enumerator *E=(Enumerator *)GetFiberData(); // get the context, stored in fiber data

    if (E->Fiber!=GetCurrentFiber()) // check, if it is the same fiber - 

                                        // Fiber field is spoofed at cleanup

    {
        *E->pResult=value; // set the result

        SwitchToFiber(E->Fiber); // return to main fiber

    }
}

 

源代码原文下载:
Yield Return Iterator for Native C++ Using Fibers The Microsoft .NET technology in C# version 2.0 introduced new langage feature - the "yield return" keyword used in iterating across collections (and not only collections). This article shows how to create a similar iterating technique in native C++. Unlike most (recent) C++ libraries, it does not require highly complicated code to be used by the end-developer.

源码图片

从本站下载附件及源代码(1个附件,已经成功下载20次)

最值得关注的外文源代码

3D OpenGL Billard Simulator
评论(评论是增加积分的一个有效途径)
字数在300字内
请如实评论
本源代码共评论37次,此处显示最近20次评论! 查看所有评论

sxlpc  2021年11月07日
-再站坏越抗quanmin.baidu.com/v/4165247181294807793 -喂俾钾柑木quanmin.baidu.com/sv?source=share-h5&pd=qm_share_search&vid=4165247181294807793 -钢压侄仁馗quanmin.baidu.com/sv?source=share-h5&vid=4165247181294807793
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
CpjJwWHV  2020年09月11日
1
天涯沙漠  2015年08月16日
不错啊
lieshou  2014年09月10日
很好地
renmg123  2013年12月19日
谢谢楼主分享
字数在300字内
请如实评论
200万国内源码搜索
CopyRight (C) codesoso.com 2007-2009 All Rights Reserved zhihuishi   免责声明