在一个变量中使用std :: move之后,该变量可能是类中的一个字段,如:
class A {
public:
vector<string>&& stealVector() {
return std::move(myVector);
}
void recreateMyVector() {
}
private:
vector<string> myVector;
};
Run Code Online (Sandbox Code Playgroud)
我如何重新创建矢量,就像一个清晰的矢量?在std :: move之后myVector中还剩下什么?
strptime
当我们有毫秒时间的日期时间字符串时,下一个最好的事情是什么?
鉴于:
"30/03/09 16:31:32.121"
Run Code Online (Sandbox Code Playgroud)
我们不能使用常规strptime因为struct tm
不存储毫秒.是否有新的课程可以实现这一目标?
我想要一个类返回的类,this
所以我可以做嵌套集.但我的问题是子类也有一些集合,但如果API的用户首先调用超类中的一个集合,则类型会发生变化,我无法调用子类方法.
class SuperA {
public:
SuperA* setValue(int x) {
return this;
}
}
class SubA : public SuperA {
public:
SubA* setOtherValue(int y) {
return this;
}
}
SubA* a = new SubA();
a->setValue(1)->setOtherValue(12); // Compile error
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?谢谢