aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-10-25 06:01:50 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-10-25 06:01:50 +0300
commitee372e0d9cbb352fe25c870d5492727eb5584764 (patch)
treee8478b5acc3208c62603f243d7d319b31258b6c7
parentadd nrvo_by_default/ (diff)
downloadblog-ee372e0d9cbb352fe25c870d5492727eb5584764.tar.gz
blog-ee372e0d9cbb352fe25c870d5492727eb5584764.zip
nrvo: add more test cases
-rw-r--r--nrvo_by_default/.gitignore1
-rw-r--r--nrvo_by_default/rvo.cpp47
2 files changed, 48 insertions, 0 deletions
diff --git a/nrvo_by_default/.gitignore b/nrvo_by_default/.gitignore
new file mode 100644
index 0000000..b883f1f
--- /dev/null
+++ b/nrvo_by_default/.gitignore
@@ -0,0 +1 @@
+*.exe
diff --git a/nrvo_by_default/rvo.cpp b/nrvo_by_default/rvo.cpp
index f8c8f32..e8ac6fd 100644
--- a/nrvo_by_default/rvo.cpp
+++ b/nrvo_by_default/rvo.cpp
@@ -44,11 +44,22 @@ namespace
return C{};
}
+ C make_prevent_rvo()
+ {
+ return std::move(C{});
+ }
+
C make_nrvo()
{
C c;
return c;
}
+
+ C make_prevent_nrvo()
+ {
+ C c;
+ return std::move(c);
+ }
}
int main()
@@ -69,5 +80,41 @@ int main()
std::cout << "C c = make_rvo()\n";
C c = make_rvo();
}
+ {
+ std::cout << "C c(make_nrvo())\n";
+ C c(make_nrvo());
+ }
+ {
+ std::cout << "C c{make_nrvo())\n";
+ C c{make_nrvo()};
+ }
+ {
+ std::cout << "C c = make_nrvo()\n";
+ C c{make_nrvo()};
+ }
+ {
+ std::cout << "C c(make_prevent_rvo())\n";
+ C c(make_prevent_rvo());
+ }
+ {
+ std::cout << "C c{make_prevent_rvo()}\n";
+ C c{make_prevent_rvo()};
+ }
+ {
+ std::cout << "C c = make_prevent_rvo()\n";
+ C c = make_prevent_rvo();
+ }
+ {
+ std::cout << "C c(make_prevent_nrvo())\n";
+ C c(make_prevent_nrvo());
+ }
+ {
+ std::cout << "C c{make_prevent_nrvo()}\n";
+ C c{make_prevent_nrvo()};
+ }
+ {
+ std::cout << "C c = make_prevent_nrvo()\n";
+ C c = make_prevent_nrvo();
+ }
return 0;
}