Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

quick confirmation needed

40 views
Skip to first unread message

Doug Mika

unread,
Apr 16, 2015, 3:55:44 PM4/16/15
to
Hi, could someone quickly confirm if the following last line calls the copy constructor? Thanx

bitset<4> fourBits1("1010");
bitset<4> fourBits2("1111");
bitset<4> result(fourBits1 & fourBits2);

Victor Bazarov

unread,
Apr 16, 2015, 4:34:20 PM4/16/15
to
The compiler is allowed to optimize away copy construction. Just keep
that in mind. The semantics might require creating a copy but the
reality can be slightly different in the name of performance. You can
only confirm that the copy constructor is called by putting the
breakpoint in it and running under a debugger, or by introducing some
kind of side effect code and observing that the side effect takes place.

V
--
I do not respond to top-posted replies, please don't ask

Mr Flibble

unread,
Apr 16, 2015, 4:46:54 PM4/16/15
to
Note: attempting to introduce a side effect to copy ctor is not enough
to prevent copy constructor elision taking place sausages.

/Flibble

0 new messages