Behnam Esmaili
Behnam Esmaili

Reputation: 5967

c++ parenthesis in front of member variable

I am translating a c++ code to another language and am having difficulties understanding some code block in c++ code.Here is the line i am having trouble understanding the concept.

here is code snippet :

DynamicUint &operator=(const DynamicUintView<Iterator> that) &
      {
        view(*this) = that; // <== this line seems weird
        return *this;
      }  

in view(*this) = that; what i've grasped is it is trying to initialize view member variable by (*this) value as parameter but as far as i saw there is no constructor taking one arguments in DynamicUintView class.could somebody shed some light on this?

Upvotes: 1

Views: 106

Answers (1)

cdhowie
cdhowie

Reputation: 168988

view is a type alias for DynamicUintView<iterator>, so this code does the following:

  1. Constructs a temporary DynamicUintView<iterator> object by invoking the implicit DynamicUintView<iterator> conversion operator, which in turn invokes the two-arg constructor of DynamicUintView<iterator>.
  2. view::operator= is invoked on this temporary object, passing that as the argument.

Upvotes: 2

Related Questions