在重新分配时,在确定是否移动或复制元素之前,向量将检查移动构造函数是否标记为noexcept.默认移动构造函数是否定义为noexcept?我看到了以下文档,但没有说明这一点.http://en.cppreference.com/w/cpp/language/move_constructor
隐式声明的移动构造函数
如果没有为类类型(结构,类或联合)提供用户定义的移动构造函数,并且满足以下所有条件:没有用户声明的复制构造函数没有用户声明的复制赋值运算符没有用户声明的移动赋值运算符没有用户声明的析构函数,由于下一节中详述的条件,隐式声明的移动构造函数未定义为已删除,因此编译器将声明移动构造函数作为其类的内联公共成员signature T :: T(T &&)一个类可以有多个移动构造函数,例如T :: T(const T &&)和T :: T(T &&).如果存在一些用户定义的移动构造函数,则用户仍可以使用关键字default强制生成隐式声明的移动构造函数.
我使用extern C函数返回动态分配const char*.
我想用来unique_ptr<const char, decltype(std::free)>管理它.
但是没有std::free(const void*)超载,所以我得到invalid conversion from 'const void*' to 'void*'并且必须使用const_cast<char*>().
这仅仅是标准库不完善还是背后还有其他东西?
有没有办法访问 boost msm 中的所有状态(不仅是活动状态)?例如,放置在状态中的所有 UI 控件都应该在调整大小事件时调整大小,无论它们的状态是否活动。
更新:让我澄清一下,我需要某种迭代器来遍历我的状态机创建的所有对象状态。
更新#2:下面是一个示例。我需要调用所有状态的resize方法。
struct EventOne {};
struct EventTwo {};
struct StateOne : public state<> {
void resize() { }
};
struct StateTwo : public state<> {
void resize() { }
};
struct MyFsm : public state_machine_def<MyFsm> {
typedef int no_exception_thrown;
typedef StateOne initial_state;
struct transition_table : boost::mpl::vector<
// Start, Event, Next, Action, Guard
Row< StateOne, EventOne, StateTwo, none, none >,
Row< StateTwo, EventTwo, StateOne, none, none >
> {
};
};
typedef boost::msm::back::state_machine<MyFsm> Fsm;
Run Code Online (Sandbox Code Playgroud)