---------------
Christof Meerwald@freec++.prog

home
> prog
>> freecpp
>>> return value opt

translate to German (by SYSTRAN)

Empty Base Class Optimization

see Return Value Optimization.

> return_value_opt.cpp:

struct A
{
  inline A()
    : copied_(0)
  { }

  inline A(const A &)
    : copied_(1)
  { }

  inline A &operator =(const A &)
  {
    copied_ = 1;
    return *this;
  }

  bool copied_;
};


A f()
{
  A a;

  return a;
}


int main(int argc, char *argv[])
{
  A a = f();

  return a.copied_ ? 1 : 0;
}
---------------

This Web page is licensed under the Creative Commons Attribution - NonCommercial - Share Alike License. Any use is subject to the Privacy Policy.

Revision: 1.2, cmeerw.org/prog/freecpp/return_value_opt.html
Last modified: Mon Sep 03 18:20:50 2018
Christof Meerwald <cmeerw@cmeerw.org>
XMPP: cmeerw@cmeerw.org