Function dual to std::move?

后端 未结 3 784
刺人心
刺人心 2020-12-21 09:58

Let\'s assume I have a class with only one constructor:

class T {
 public:
  T(BigClass&& big) : big(std::move(big)) {}
  ...

  SomeBigClass
};
         


        
3条回答
  •  自闭症患者
    2020-12-21 10:32

    It's not hard to write:

    template 
    T make_temp(const T& x) { return x; }
    

    There might be a standard function that happens to do that by accident when called with one argument, but there isn't one designed for this unusual pattern.

提交回复
热议问题