惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
The GitHub Blog
The GitHub Blog
美团技术团队
Security Latest
Security Latest
The Cloudflare Blog
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Security Affairs
腾讯CDC
H
Hacker News: Front Page
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 三生石上(FineUI控件)
C
Check Point Blog
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
量子位
Apple Machine Learning Research
Apple Machine Learning Research
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
月光博客
月光博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
D
Docker
Hugging Face - Blog
Hugging Face - Blog
I
Intezer
雷峰网
雷峰网
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
SecWiki News
SecWiki News
N
News and Events Feed by Topic

博客园 - Michael Peng

用马尔科夫模型做拼写检查 商业软件编程很无聊(转载) VS2010 Debugger bug 编程之初 编程之美 1.4买书问题常数时间空间解法 vc2010 std::tr1 bind库捉虫记 用vs2010编译kigg 3.0遇到的问题 在vs中获得当前所有快捷键代码 最近的一些面试感悟 error C2065: '__LINE__Var' : undeclared identifier 写错名字了 啰嗦几句,关于动机,学习与批评,架构和代码风格 金山卫士代码批评 24点计算 部门开始做技术talk 数据库的坏味道 --《Refactoring Database: Evolutionary Database Design》读书笔记 偷天换日 初识rails ruby解数独问题
这两天被vs2010的std::tr1::bind郁闷了
Michael Peng · 2010-12-08 · via 博客园 - Michael Peng

    std::tr1::function<bool(bool)> f4 = 
        std::tr1::bind(
            std::logical_and
<bool>(),
            std::tr1::bind(std::logical_not
<bool>(), std::tr1::placeholders::_1),
            
true);

想在vs2010里玩一玩function programming,却被郁闷了,又发现了一个别人发现过的bug

A bug about std::tr1::bind 

Microsoft 在 2009/8/7 18:33 发送

Hi,

Thanks for reporting this bug. Unfortunately, we have resolved it as Won't Fix for VC10. Our implementation is fragile when it comes to nested bind(), and we'll need to devote significant time to fixing it - time we don't have for VC10. (I can't promise anything, but I hope to be able to rewrite bind()'s implementation when we get variadic templates.)

The good news is that lambdas in VC10 supersede bind() in 99% of cases. Lambdas offer much more natural syntax (especially compared to nested bind()) and greater efficiency, since the optimizer can inline lambdas but has difficulty with bind()'s functors.

Here's an example that expresses your bind() functor as a lambda (doing something slightly different with it, but the functor has the same behavior):

C:\Temp>type meow.cpp
#include <algorithm>
#include <iostream>
#include <iterator>
#include <ostream>
#include <vector>
using namespace std;

int main() {
    vector<int> v;
    v.push_back(2);
    v.push_back(4);
    v.push_back(6);
    v.push_back(8);
    v.push_back(1);
    v.push_back(3);
    v.push_back(5);
    v.push_back(7);
    v.push_back(9);

    vector<int> dest;

    copy_if(v.begin(), v.end(), back_inserter(dest), [](int n) { return n >= 3 && n <= 8; });

    for_each(dest.begin(), dest.end(), [](int n) { cout << n << " "; });
    cout << endl;
}

C:\Temp>cl /EHsc /nologo /W4 meow.cpp
meow.cpp

C:\Temp>meow
4 6 8 3 5 7

Until you get VC10, remember that handwritten functors are always an alternative to using bind().

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer

Microsoft 在 2009/4/22 23:36 发送

Thanks for your feedback.

We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team

 

只好换boost或者lambda