Corresponds to the QuantLib ReplicatingVarianceSwap Engine.
The methodology is based on the work of Demeterfi, Derman, Kamal and Zou. Web reference available here
The main idea is that a certain replicating portfolio of european call and put options exists, the payoff of which converges to the annualized variance of the daily underlying price returns, as the number of portfolio constituents increases.
As a matter of fact, such a portfolio provides a perfect static hedge to the variance swap, without the need for delta hedge rebalancing.
The weights and constituents of the replicating portfolio are also returned as additional output along the price of the variance swap.
Note the "realized variance" returned by QuanLib is the one implied by the portfolio of options presumed to replicate the variance swap and as such it will converge to the actual realized variance as more options are included.