diff options
Diffstat (limited to 'nrvo_by_default')
-rw-r--r-- | nrvo_by_default/.gitignore | 2 | ||||
-rw-r--r-- | nrvo_by_default/Makefile | 26 | ||||
-rw-r--r-- | nrvo_by_default/nmake.mk | 21 | ||||
-rw-r--r-- | nrvo_by_default/rvo.cpp | 125 |
4 files changed, 0 insertions, 174 deletions
diff --git a/nrvo_by_default/.gitignore b/nrvo_by_default/.gitignore deleted file mode 100644 index 25e9f74..0000000 --- a/nrvo_by_default/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.obj -*.exe diff --git a/nrvo_by_default/Makefile b/nrvo_by_default/Makefile deleted file mode 100644 index 13feb31..0000000 --- a/nrvo_by_default/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Builds rvo.cpp on various optimization levels supported by GCC. -# The compiler is `g++` by default. -# You can change the compiler to be used using the CXX variable. -# For example, if you want to compile using `x86_64-w64-mingw32-g++`, run -# -# > make CXX=x86_64-w64-mingw32-g++ - -CXXFLAGS = -Wall -Wextra -DNDEBUG -std=c++11 -static -s - -optimization_levels = 0 1 2 3 - -all:: - -define make_target -rvo.$(CXX).O$(1).exe: rvo.cpp - $(CXX) $(CXXFLAGS) -O$(1) $$< -o $$@ - -all:: rvo.$(CXX).O$(1).exe -endef - -$(foreach i,$(optimization_levels),$(eval $(call make_target,$(i)))) - -.PHONY: clean-all - -clean-all: - $(RM) $(wildcard rvo.$(CXX).*.exe) diff --git a/nrvo_by_default/nmake.mk b/nrvo_by_default/nmake.mk deleted file mode 100644 index 45aefd4..0000000 --- a/nrvo_by_default/nmake.mk +++ /dev/null @@ -1,21 +0,0 @@ -CXXFLAGS = /nologo /W4 /EHsc /MT /DNDEBUG - -all: rvo.cl.Od.exe rvo.cl.O1.exe rvo.cl.O2.exe rvo.cl.Ox.exe - -rvo.cl.Od.exe: rvo.cpp - $(CXX) $(CXXFLAGS) /Od /Fe:$@ $** - -rvo.cl.O1.exe: rvo.cpp - $(CXX) $(CXXFLAGS) /O1 /Fe:$@ $** - -rvo.cl.O2.exe: rvo.cpp - $(CXX) $(CXXFLAGS) /O2 /Fe:$@ $** - -rvo.cl.Ox.exe: rvo.cpp - $(CXX) $(CXXFLAGS) /Ox /Fe:$@ $** - -clean: - del rvo.obj - -clean-all: clean - del rvo.cl.*.exe diff --git a/nrvo_by_default/rvo.cpp b/nrvo_by_default/rvo.cpp deleted file mode 100644 index a1e73e5..0000000 --- a/nrvo_by_default/rvo.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> -// This file is part of the "Egor's blog" project. -// For details, see https://github.com/egor-tensin/blog. -// Distributed under the MIT License. - -#include <iostream> -#include <utility> - -namespace -{ - class C - { - public: - explicit C() - { - std::cout << "\tC::C()\n"; - } - - C(C&&) noexcept - { - std::cout << "\tC::C(C&&)\n"; - } - - C(const C&) - { - std::cout << "\tC::C(const C&)\n"; - } - - C& operator=(C&&) noexcept - { - std::cout << "\tC::operator=(C&&)\n"; - return *this; - } - - C& operator=(const C&) - { - std::cout << "\tC::operator=(const C&)\n"; - return *this; - } - - ~C() - { - std::cout << "\tC::~C()\n"; - } - }; - - C make_rvo() - { - 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() -{ - { - std::cout << "C c\n"; - C c; - } - { - std::cout << "C c(make_rvo())\n"; - C c(make_rvo()); - } - { - std::cout << "C c{make_rvo()}\n"; - C c{make_rvo()}; - } - { - 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; -} |