Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -376,19 +376,19 @@
};

void g() {
shared_ptr<A> sp1 = factory<A>(2, 1.414); // error: 2 will not bind to \tcode{int\&}
shared_ptr<A> sp1 = factory<A>(2, 1.414); // error: \tcode{2} will not bind to \tcode{int\&}
int i = 2;
shared_ptr<A> sp2 = factory<A>(i, 1.414); // OK
}
\end{codeblock}
In the first call to \tcode{factory},
\tcode{A1} is deduced as \tcode{int}, so 2 is forwarded
\tcode{A1} is deduced as \tcode{int}, so \tcode{2} is forwarded
to \tcode{A}'s constructor as an rvalue.
In the second call to \tcode{factory},
\tcode{A1} is deduced as \tcode{int\&}, so \tcode{i} is forwarded
to \tcode{A}'s constructor as an lvalue. In
both cases, \tcode{A2} is deduced as \tcode{double}, so
1.414 is forwarded to \tcode{A}'s constructor as an rvalue.
\tcode{1.414} is forwarded to \tcode{A}'s constructor as an rvalue.
\end{example}
\end{itemdescr}

Expand Down