我试图理解io_service的poll()/ poll_one()和run()/ run_one()之间的区别.文档中陈述的差异是poll()执行就绪处理程序而不是执行任何处理程序的run().
但是在boost文档中我找不到"就绪处理程序"的定义.
这个问题的一个有效答案是能够最好地用代码示例显示就绪和非就绪处理程序之间的区别以及poll()和run()如何执行它之间的区别.
谢谢.
这看起来像编译器错误,但案件很简单,我有点怀疑,所以我正在寻找确认.可与VS2010和VS2012一起重现.以下示例无法编译.给出了这个错误:
错误1错误C2440:'type cast':无法从'ConvertibleToAny'转换为'OtherType <_Ty>'test.cpp 40
如果将移动构造函数的位置移动到构造函数OtherType(ThisType &&)上方OtherType( int ),它会突然编译.
#include "stdafx.h"
#include <string>
using namespace std;
template<class _Ty>
struct OtherType
{
typedef OtherType<_Ty> ThisType;
OtherType()
{
}
OtherType( int )
{
}
// The move constructor
OtherType(ThisType && )
{
}
};
struct ConvertibleToAny
{
template <class AnyType>
operator AnyType()
{
return AnyType();
}
};
int _tmain(int argc, _TCHAR* argv[])
{
(OtherType<wstring>) ConvertibleToAny();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是一个错误还是这个预期的行为?如果是预期的,请引用C++ 11规范中的相关段落.我已将此作为Microsoft Connect中的错误发布,请单击此处将其打开.
请考虑以下代码,该代码在VS2012中编译但在VS2010中因错误而失败
1>------ Build started: Project: testconstinit, Configuration: Debug Win32 ------
1> testconstinit.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(48): error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
1> with
1> [
1> _Ty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\memory(2347) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr'
1> with
1> [
1> _Ty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(197) : see reference to function template instantiation 'void std::_Construct<std::unique_ptr<_Ty>,const std::unique_ptr<_Ty>&>(_Ty1 *,_Ty2)' being compiled
1> with …Run Code Online (Sandbox Code Playgroud)