|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81363 - sandbox/icl/libs/icl/example/tmp_move_
From: afojgo_at_[hidden]
Date: 2012-11-16 02:54:28
Author: jofaber
Date: 2012-11-16 02:54:20 EST (Fri, 16 Nov 2012)
New Revision: 81363
URL: http://svn.boost.org/trac/boost/changeset/81363
Log:
Some temporary move experiments.
Added:
sandbox/icl/libs/icl/example/tmp_move_/
sandbox/icl/libs/icl/example/tmp_move_/move.cpp (contents, props changed)
sandbox/icl/libs/icl/example/tmp_move_/vc11_move.sln (contents, props changed)
sandbox/icl/libs/icl/example/tmp_move_/vc11_move.vcproj (contents, props changed)
Added: sandbox/icl/libs/icl/example/tmp_move_/move.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/icl/example/tmp_move_/move.cpp 2012-11-16 02:54:20 EST (Fri, 16 Nov 2012)
@@ -0,0 +1,176 @@
+#include <iostream>
+
+using namespace std;
+
+
+class Mob
+{
+public:
+
+ Mob(int val=0): _mine(new int)
+ {
+ cout << ".";
+ *_mine = val;
+ }
+
+ Mob(const Mob& src):_mine(new int)
+ {
+ cout << "[copy].";
+ *_mine = *(src._mine);
+ }
+
+ Mob& operator = (const Mob& src)
+ {
+ if(this != &src)
+ {
+ cout << "[c=]";
+ //delete _mine;
+ //_mine = new int;
+ *_mine = *(src._mine);
+ }
+ return *this;
+ }
+
+ Mob(Mob&& victim): _mine(victim._mine) //Klau
+ {
+ cout << "[move]";
+ victim._mine = 0; //Dtor wird gleich aufgerufen.
+ }
+
+ Mob& operator = (Mob&& victim)
+ {
+ if(this != &victim)
+ {
+ cout << "[m=]~";
+ delete _mine;
+ _mine = victim._mine; //Klau
+ victim._mine = 0; //Dtor wird gleich aufgerufen.
+ }
+ return *this;
+ }
+
+ ~Mob()
+ {
+ if(_mine)
+ cout << "~" ;
+ else
+ cout << "'";
+ delete _mine;
+ }
+
+ int mine()const
+ {
+ return *_mine;
+ }
+
+ void inc()
+ {
+ ++(*_mine);
+ }
+
+ Mob& operator += (const Mob& addend)
+ {
+ *_mine += *(addend._mine);
+ return *this;
+ }
+
+private:
+ int* _mine;
+};
+
+
+//Mob operator + (const Mob& lhs, const Mob& rhs)
+//{
+// return lhs.mine() + rhs.mine();
+//}
+
+//Mob operator + (const Mob& lhs, const Mob& rhs)
+//{
+// Mob tmp(lhs);
+// return std::move(tmp += rhs);
+//}
+
+Mob operator + (Mob&& lhs, const Mob& rhs)
+{
+ return std::move(lhs += rhs);
+}
+
+/*msvc-11 only
+Mob inc_a_tmp(Mob& x)
+{
+ cout << "[f(&)]";
+ x.inc();
+ return move(x);
+}
+*/
+
+Mob inc(Mob&& x)
+{
+ cout << "[inc(&&)]";
+ x.inc();
+ return std::move(x);
+}
+
+Mob inc(Mob& x)
+{
+ cout << "[inc(&)]";
+ x.inc();
+ return x;
+}
+
+Mob mob_answer1()
+{
+ return Mob(40)+Mob(2); //Call move ctor
+}
+
+Mob mob_answer2()
+{
+ Mob tmp;
+ tmp = Mob(40)+Mob(2); //Calls move assign
+ return tmp; //Calls move ctor
+}
+
+
+int g(int&& x){ return x++; }
+
+void test1()
+{
+ //cout << "Test: " << (Mob(1) + Mob(2)).mine() << endl;
+ Mob mc = inc(Mob(1) + Mob(2));
+ cout << "Test 1. Expect:4 Get:" << mc.mine() << endl;
+ cout << "mob_answer1()" << endl;
+ mob_answer1();
+ cout << endl;
+ //cout << "Mob answer1: " << mob_answer1().mine() << endl;
+ cout << "mob_answer2()" << endl; mob_answer2(); cout << endl;
+ //int answer2 = mob_answer2().mine();
+ //cout << "Mob answer2: " << mob_answer2().mine() << endl;
+
+ cout << endl;
+ Mob a3 = Mob(1) + Mob(2);
+ cout << "\n1+2=" << a3.mine() << endl;
+
+ cout << endl;
+ Mob a6 = (Mob(1) + Mob(2)) + Mob(3);
+ cout << "\n1+2+3=" << a6.mine() << endl;
+
+ cout << endl;
+ Mob a6r = Mob(1) + (Mob(2) + Mob(3));
+ cout << "\n1+(2+3)=" << a6r.mine() << endl;
+}
+
+void test_bindings()
+{
+ int a = 1, b = 2;
+ cout << "test_bindings(). Expect: 4 Get: " << g(a+b) << endl;
+}
+
+int main()
+{
+ cout << ">>Testing move <<\n";
+ cout << "-------------------------------------------------------\n";
+ test1();
+ //test_bindings();
+ return 0;
+}
+
Added: sandbox/icl/libs/icl/example/tmp_move_/vc11_move.sln
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/icl/example/tmp_move_/vc11_move.sln 2012-11-16 02:54:20 EST (Fri, 16 Nov 2012)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D12-00A0C91BC942}") = "vc11_move", "vc11_move.vcxproj", "{DD9C9854-3882-42B9-BFA3-AA054DD43759}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DD9C9854-3882-42B9-BFA3-AA054DD43759}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DD9C9854-3882-42B9-BFA3-AA054DD43759}.Debug|Win32.Build.0 = Debug|Win32
+ {DD9C9854-3882-42B9-BFA3-AA054DD43759}.Release|Win32.ActiveCfg = Release|Win32
+ {DD9C9854-3882-42B9-BFA3-AA054DD43759}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: sandbox/icl/libs/icl/example/tmp_move_/vc11_move.vcproj
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/icl/example/tmp_move_/vc11_move.vcproj 2012-11-16 02:54:20 EST (Fri, 16 Nov 2012)
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{DD9C9854-3882-42B9-BFA3-AA054DD43759}</ProjectGuid>
+ <RootNamespace>Move</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and $(VisualStudioVersion) == ''">$(VCTargetsPath11)</VCTargetsPath>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../bin/debug/\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../bin/obj/$(ProjectName)/debug/\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../bin/release/\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../bin/obj/$(ProjectName)/release/\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>../../../../bin/debug/$(ProjectName).exe</OutputFile>
+ <AdditionalLibraryDirectories>../../../../lib;../../boost_1_35_0/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AssemblyDebug>true</AssemblyDebug>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>../../../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <OutputFile>../../../../bin/release/$(ProjectName).exe</OutputFile>
+ <AdditionalLibraryDirectories>../../../../lib;../../boost_1_35_0/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="move.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk