Content-Length: 579571 | pFad | http://github.com/gusenov/examples-cpp/commit/f2e60b6d3d61cfcb7cc69aba1081162ce2de5193

19 shared_from_this работает после конвертации из unique_ptr в shared_ptr. · gusenov/examples-cpp@f2e60b6 · GitHub
Skip to content

Commit f2e60b6

Browse files
committed
shared_from_this работает после конвертации из unique_ptr в shared_ptr.
1 parent e1beb24 commit f2e60b6

File tree

9 files changed

+150
-2
lines changed

9 files changed

+150
-2
lines changed

smart-ptr/shared_ptr/shared-from-this/.gitignore

+90
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,93 @@
3535
*.app
3636

3737
# ---------------------------------------------------------------------------
38+
# https://github.com/github/gitignore/blob/master/CMake.gitignore
39+
40+
CMakeLists.txt.user
41+
CMakeCache.txt
42+
CMakeFiles
43+
CMakeScripts
44+
Testing
45+
Makefile
46+
cmake_install.cmake
47+
install_manifest.txt
48+
compile_commands.json
49+
CTestTestfile.cmake
50+
_deps
51+
52+
# ---------------------------------------------------------------------------
53+
# https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
54+
55+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
56+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
57+
58+
# User-specific stuff
59+
.idea/**/workspace.xml
60+
.idea/**/tasks.xml
61+
.idea/**/usage.statistics.xml
62+
.idea/**/dictionaries
63+
.idea/**/shelf
64+
65+
# Generated files
66+
.idea/**/contentModel.xml
67+
68+
# Sensitive or high-churn files
69+
.idea/**/dataSources/
70+
.idea/**/dataSources.ids
71+
.idea/**/dataSources.local.xml
72+
.idea/**/sqlDataSources.xml
73+
.idea/**/dynamic.xml
74+
.idea/**/uiDesigner.xml
75+
.idea/**/dbnavigator.xml
76+
77+
# Gradle
78+
.idea/**/gradle.xml
79+
.idea/**/libraries
80+
81+
# Gradle and Maven with auto-import
82+
# When using Gradle or Maven with auto-import, you should exclude module files,
83+
# since they will be recreated, and may cause churn. Uncomment if using
84+
# auto-import.
85+
# .idea/artifacts
86+
# .idea/compiler.xml
87+
# .idea/jarRepositories.xml
88+
# .idea/modules.xml
89+
# .idea/*.iml
90+
# .idea/modules
91+
# *.iml
92+
# *.ipr
93+
94+
# CMake
95+
cmake-build-*/
96+
97+
# Mongo Explorer plugin
98+
.idea/**/mongoSettings.xml
99+
100+
# File-based project format
101+
*.iws
102+
103+
# IntelliJ
104+
out/
105+
106+
# mpeltonen/sbt-idea plugin
107+
.idea_modules/
108+
109+
# JIRA plugin
110+
atlassian-ide-plugin.xml
111+
112+
# Cursive Clojure plugin
113+
.idea/replstate.xml
114+
115+
# Crashlytics plugin (for Android Studio and IntelliJ)
116+
com_crashlytics_export_strings.xml
117+
crashlytics.properties
118+
crashlytics-build.properties
119+
fabric.properties
120+
121+
# Editor-based Rest Client
122+
.idea/httpRequests
123+
124+
# Android studio 3.1+ serialized cache file
125+
.idea/caches/build_file_checksums.ser
126+
127+
# ---------------------------------------------------------------------------

smart-ptr/shared_ptr/shared-from-this/.idea/.gitignore

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smart-ptr/shared_ptr/shared-from-this/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smart-ptr/shared_ptr/shared-from-this/.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smart-ptr/shared_ptr/shared-from-this/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smart-ptr/shared_ptr/shared-from-this/.idea/shared-from-this.iml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smart-ptr/shared_ptr/shared-from-this/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(SharedFromThis)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
add_executable(${PROJECT_NAME} main.cc)

smart-ptr/shared_ptr/shared-from-this/main.cc

+27-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,34 @@ void test1() {
3030

3131
std::cout << "end;" << std::endl;
3232
}
33+
/*
34+
Clazz()
35+
end;
36+
~Clazz()
37+
end.
38+
*/
3339

34-
int main(int argc, char const * argv[]) {
35-
test1();
40+
void test2()
41+
{
42+
std::shared_ptr<Clazz> a;
43+
44+
{
45+
std::shared_ptr<Clazz> b = std::make_unique<Clazz>();
46+
a = b->shared();
47+
}
48+
49+
std::cout << "end;" << std::endl;
50+
}
51+
/*
52+
Clazz()
53+
end;
54+
~Clazz()
55+
end.
56+
*/
57+
58+
int main(int argc, char const * argv[])
59+
{
60+
test2();
3661

3762
std::cout << "end." << std::endl;
3863
return EXIT_SUCCESS;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/gusenov/examples-cpp/commit/f2e60b6d3d61cfcb7cc69aba1081162ce2de5193

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy