1

Let's say I got a class which takes two parameters when constructing. And I need to deal with the rvalue/lvale, does that mean I should write 4 constructors?

class Test {
 public:
  Test(const A& a, const B& b) {}
  Test(const A& a, B&& b) {}
  Test(A&& a, const B& b) {}
  Test(A&& a, B&& b) {}
};

Is there any way I can do this easier? Or is this design pattern wrong?

0 Answers0