2014-09-03 64 views
1

我的环境:RadStudio XE4 UPDATE1上Windows7pro(32位)E2316使用的std ::功能

我试图研究以下占位符页面 http://en.cppreference.com/w/cpp/utility/functional/placeholders

以下是代码,我试图编译。

... 

#include <functional> 
#include <string> 
#include <iostream> 

... 

static void goodbye(const std::string &s) 
{ 
    std::cout << "Goodbye " << s << std::endl; 
} 

class Object { 
public: 
    void hello(const std::string &s) 
    { 
     std::cout << "Hello " << s << std::endl; 
    } 
}; 


void __fastcall TForm1::Button1Click(TObject *Sender) 
{ 
    // [bcc32 error] ...:E2316 'function' is not a member of 'std' 
    typedef std::function<void(const std::string &)> ExampleFunction; 
} 

在上面的代码中,我得到了typedef语句中的E2316错误。

我应该怎么做才能纠正这个错误?

回答

1

这在bcc32中不起作用。首先,bcc32不符合C++ 11标准,因此您必须使用boost::function

其次,bcc32不支持规格void(const std::string &)QC 126470)。

没有解决方法。您必须完全放弃std::function的想法,并推出自己的解决方案(可能使用bcc32扩展__closure)。

它应该工作在bcc64。