Skip to content

Commit e4be2ea

Browse files
Владимир СеверовВладимир Северов
authored andcommitted
17.03.22 01:11 - Release
1 parent 01ee110 commit e4be2ea

File tree

5 files changed

+283
-0
lines changed

5 files changed

+283
-0
lines changed

M2-LW-9/M2-LW-9.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "M2-LW-9", "M2-LW-9\M2-LW-9.vcxproj", "{46F6DBCF-7C54-49CF-A749-BC37115764B6}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Debug|x64.ActiveCfg = Debug|x64
17+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Debug|x64.Build.0 = Debug|x64
18+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Debug|x86.ActiveCfg = Debug|Win32
19+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Debug|x86.Build.0 = Debug|Win32
20+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Release|x64.ActiveCfg = Release|x64
21+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Release|x64.Build.0 = Release|x64
22+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Release|x86.ActiveCfg = Release|Win32
23+
{46F6DBCF-7C54-49CF-A749-BC37115764B6}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

M2-LW-9/M2-LW-9/M2-LW-9.vcxproj

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{46F6DBCF-7C54-49CF-A749-BC37115764B6}</ProjectGuid>
23+
<RootNamespace>M2LW9</RootNamespace>
24+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
25+
</PropertyGroup>
26+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
28+
<ConfigurationType>Application</ConfigurationType>
29+
<UseDebugLibraries>true</UseDebugLibraries>
30+
<PlatformToolset>v140</PlatformToolset>
31+
<CharacterSet>MultiByte</CharacterSet>
32+
</PropertyGroup>
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
34+
<ConfigurationType>Application</ConfigurationType>
35+
<UseDebugLibraries>false</UseDebugLibraries>
36+
<PlatformToolset>v140</PlatformToolset>
37+
<WholeProgramOptimization>true</WholeProgramOptimization>
38+
<CharacterSet>MultiByte</CharacterSet>
39+
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
41+
<ConfigurationType>Application</ConfigurationType>
42+
<UseDebugLibraries>true</UseDebugLibraries>
43+
<PlatformToolset>v140</PlatformToolset>
44+
<CharacterSet>MultiByte</CharacterSet>
45+
</PropertyGroup>
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
47+
<ConfigurationType>Application</ConfigurationType>
48+
<UseDebugLibraries>false</UseDebugLibraries>
49+
<PlatformToolset>v140</PlatformToolset>
50+
<WholeProgramOptimization>true</WholeProgramOptimization>
51+
<CharacterSet>MultiByte</CharacterSet>
52+
</PropertyGroup>
53+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
54+
<ImportGroup Label="ExtensionSettings">
55+
</ImportGroup>
56+
<ImportGroup Label="Shared">
57+
</ImportGroup>
58+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
</ImportGroup>
67+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
68+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
69+
</ImportGroup>
70+
<PropertyGroup Label="UserMacros" />
71+
<PropertyGroup />
72+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73+
<ClCompile>
74+
<WarningLevel>Level3</WarningLevel>
75+
<Optimization>Disabled</Optimization>
76+
<SDLCheck>true</SDLCheck>
77+
</ClCompile>
78+
</ItemDefinitionGroup>
79+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80+
<ClCompile>
81+
<WarningLevel>Level3</WarningLevel>
82+
<Optimization>Disabled</Optimization>
83+
<SDLCheck>true</SDLCheck>
84+
</ClCompile>
85+
</ItemDefinitionGroup>
86+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
87+
<ClCompile>
88+
<WarningLevel>Level3</WarningLevel>
89+
<Optimization>MaxSpeed</Optimization>
90+
<FunctionLevelLinking>true</FunctionLevelLinking>
91+
<IntrinsicFunctions>true</IntrinsicFunctions>
92+
<SDLCheck>true</SDLCheck>
93+
</ClCompile>
94+
<Link>
95+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
96+
<OptimizeReferences>true</OptimizeReferences>
97+
</Link>
98+
</ItemDefinitionGroup>
99+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
100+
<ClCompile>
101+
<WarningLevel>Level3</WarningLevel>
102+
<Optimization>MaxSpeed</Optimization>
103+
<FunctionLevelLinking>true</FunctionLevelLinking>
104+
<IntrinsicFunctions>true</IntrinsicFunctions>
105+
<SDLCheck>true</SDLCheck>
106+
</ClCompile>
107+
<Link>
108+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
109+
<OptimizeReferences>true</OptimizeReferences>
110+
</Link>
111+
</ItemDefinitionGroup>
112+
<ItemGroup>
113+
<ClCompile Include="Source.cpp" />
114+
</ItemGroup>
115+
<ItemGroup>
116+
<ClInclude Include="ScopedPtr.h" />
117+
</ItemGroup>
118+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
119+
<ImportGroup Label="ExtensionTargets">
120+
</ImportGroup>
121+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="Source.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="ScopedPtr.h">
24+
<Filter>Header Files</Filter>
25+
</ClInclude>
26+
</ItemGroup>
27+
</Project>

M2-LW-9/M2-LW-9/ScopedPtr.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#ifndef __SCOPED_PTR__
2+
#define __SCOPED_PTR__
3+
4+
template<class T>
5+
class ScopedPtr
6+
{
7+
private:
8+
T * ptr_;
9+
public:
10+
ScopedPtr(ScopedPtr const &) = delete;
11+
ScopedPtr& operator=(ScopedPtr const &) = delete;
12+
13+
explicit ScopedPtr(T* ptr = nullptr)
14+
: ptr_(ptr)
15+
{}
16+
17+
~ScopedPtr() {
18+
delete ptr_;
19+
};
20+
21+
void reset(T* ptr = nullptr)
22+
{
23+
if (ptr != ptr_)
24+
delete ptr_;
25+
ptr_ = ptr;
26+
}
27+
28+
T& operator*() const
29+
{
30+
return *get();
31+
}
32+
33+
T* operator->() const
34+
{
35+
return get();
36+
}
37+
38+
T* get() const throw()
39+
{
40+
return ptr_;
41+
}
42+
43+
void swap(ScopedPtr & b) throw()
44+
{
45+
std::swap(ptr_, b.ptr_);
46+
}
47+
48+
bool operator! () const throw()
49+
{
50+
return ptr_ == nullptr;
51+
}
52+
53+
explicit operator bool() const throw()
54+
{
55+
return ptr_ != nullptr;
56+
}
57+
};
58+
59+
template<class T>
60+
inline bool operator==(ScopedPtr<T> const & p, std::nullptr_t) throw()
61+
{
62+
return !p;
63+
}
64+
65+
template<class T>
66+
inline bool operator==(std::nullptr_t, ScopedPtr<T> const & p) throw()
67+
{
68+
return !p;
69+
}
70+
71+
template<class T>
72+
inline bool operator!=(ScopedPtr<T> const & p, std::nullptr_t) throw()
73+
{
74+
return p;
75+
}
76+
77+
template<class T>
78+
inline bool operator!=(std::nullptr_t, ScopedPtr<T> const & p) throw()
79+
{
80+
return p;
81+
}
82+
83+
template<class T>
84+
inline void swap(ScopedPtr<T> & a, ScopedPtr<T> & b) throw()
85+
{
86+
a.swap(b);
87+
}
88+
89+
// get_pointer(p) is a generic way to say p.get()
90+
template<class T>
91+
inline T* get_pointer(ScopedPtr<T> const & p) throw()
92+
{
93+
return p.get();
94+
}
95+
96+
#endif // __SCOPED_PTR__

M2-LW-9/M2-LW-9/Source.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
#include "ScopedPtr.h"
3+
4+
int main()
5+
{
6+
ScopedPtr<int> s(new int);
7+
*s = 5;
8+
9+
system("pause");
10+
return 0;
11+
}

0 commit comments

Comments
 (0)