Pass by Value Assignment Operator?

Pages: 12
Actually, the crash probably happened because swap calls operator << with *this as an argument. As a reminder, contents was not initialized when that function was called. That's a segfaultin'.

-Albatross
Left Bit shift operator? Or ostream operator?
Last edited on
@TheToaster

1
2
3
4
5
6
7
8
9
  toy_str& swap( toy_str& that ) noexcept
    {
        std::cout << "swap " << this << ' ' << *this << " with "  // ***********<<< that one
                  << std::addressof(that) << ' ' << that << '\n' ;
        using std::swap ;
        swap( sz, that.sz ) ;
        swap( contents, that.contents ) ;
        return *this ;
    }
Got it. Thank you.
Topic archived. No new replies allowed.
Pages: 12