Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A8-4-5: Should have an exception for move constructors
#3
Yes, in the example I took from AUTOSAR, B has only one member of type "std::int32_t* ptr;".

Let's assume it has 2 such members, ptr1 and ptr2, would this be compliant with A8-4-5?

Code:
class B
{
public:
  B(B&& oth) :
    ptr1(std::move(oth.ptr1)),
    ptr2(std::move(oth.ptr2))
  {
     oth.ptr1 = nullptr;
     oth.ptr2 = nullptr;
  }
private:
   std::int32_t* ptr1;
   std::int32_t* ptr2;
};
Reply


Messages In This Thread
RE: A8-4-5: Should have an exception for move constructors - by cgpzs - 17-02-2025, 02:14 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)