Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77915 - in trunk/libs/container: proj/vc7ide test
From: igaztanaga_at_[hidden]
Date: 2012-04-11 12:02:21


Author: igaztanaga
Date: 2012-04-11 12:02:19 EDT (Wed, 11 Apr 2012)
New Revision: 77915
URL: http://svn.boost.org/trac/boost/changeset/77915

Log:
Added test for containers using scoped allocator
Added:
   trunk/libs/container/proj/vc7ide/scoped_allocator_usage_test.vcproj (contents, props changed)
   trunk/libs/container/test/scoped_allocator_usage_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/container/proj/vc7ide/container.sln | 8 ++++++++
   1 files changed, 8 insertions(+), 0 deletions(-)

Modified: trunk/libs/container/proj/vc7ide/container.sln
==============================================================================
--- trunk/libs/container/proj/vc7ide/container.sln (original)
+++ trunk/libs/container/proj/vc7ide/container.sln 2012-04-11 12:02:19 EDT (Wed, 11 Apr 2012)
@@ -47,6 +47,10 @@
         ProjectSection(ProjectDependencies) = postProject
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_allocator_usage_test", "scoped_allocator_usage_test.vcproj", "{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
 Global
         GlobalSection(SolutionConfiguration) = preSolution
                 Debug = Debug
@@ -103,6 +107,10 @@
                 {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
                 {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
                 {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
+ {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.ActiveCfg = Debug|Win32
+ {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
+ {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
+ {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(ExtensibilityGlobals) = postSolution
         EndGlobalSection

Added: trunk/libs/container/proj/vc7ide/scoped_allocator_usage_test.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/container/proj/vc7ide/scoped_allocator_usage_test.vcproj 2012-04-11 12:02:19 EDT (Wed, 11 Apr 2012)
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="scoped_allocator_usage_test"
+ ProjectGUID="{B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../Bin/Win32/Debug"
+ IntermediateDirectory="Debug/scoped_allocator_usage_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ GeneratePreprocessedFile="0"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/scoped_allocator_usage_test_d.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/scoped_allocator_usage_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ FixedBaseAddress="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../Bin/Win32/Release"
+ IntermediateDirectory="Release/scoped_allocator_usage_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/scoped_allocator_usage_test.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{41737BCF-4312-7AC5-A066-32D75A32A2AF}">
+ <File
+ RelativePath="..\..\test\scoped_allocator_usage_test.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93815995-89BD-b043-5E8B-65FBE52E2AFB}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Added: trunk/libs/container/test/scoped_allocator_usage_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/container/test/scoped_allocator_usage_test.cpp 2012-04-11 12:02:19 EDT (Wed, 11 Apr 2012)
@@ -0,0 +1,95 @@
+#include <memory>
+#include <string>
+
+#include <boost/move/move.hpp>
+#include <boost/container/map.hpp>
+#include <boost/container/scoped_allocator.hpp>
+
+template <typename Ty>
+class SimpleAllocator
+{
+public:
+ typedef Ty value_type;
+ typedef typename std::allocator<Ty>::pointer pointer;
+ typedef typename std::allocator<Ty>::size_type size_type;
+
+ SimpleAllocator(int value)
+ : _value(value)
+ {}
+
+ template <typename T>
+ SimpleAllocator(const SimpleAllocator<T> &other)
+ : _value(other._value)
+ {}
+
+ pointer allocate(size_type n)
+ {
+ return _allocator.allocate(n);
+ }
+ void deallocate(pointer p, size_type n)
+ {
+ _allocator.deallocate(p, n);
+ }
+private:
+ int _value;
+ std::allocator<Ty> _allocator;
+
+ template <typename T> friend class SimpleAllocator;
+};
+
+template <typename Ty>
+class ScopedAllocator : public boost::container::scoped_allocator_adaptor<SimpleAllocator<Ty> >
+{
+private:
+ typedef boost::container::scoped_allocator_adaptor<SimpleAllocator<Ty> > Base;
+
+public:
+ ScopedAllocator(int value)
+ : Base(SimpleAllocator<Ty>(value))
+ {}
+};
+
+class Resource
+{
+private: // Not copyable
+ Resource(const Resource &);
+ Resource &operator=(const Resource &);
+public:
+ typedef SimpleAllocator<int> allocator_type;
+
+ Resource(BOOST_RV_REF(Resource)other)
+ : _value(other._value), _allocator(boost::move(other._allocator))
+ {
+ other._value = -1;
+ }
+
+ Resource(BOOST_RV_REF(Resource)other, const allocator_type &allocator)
+ : _value(other._value), _allocator(allocator)
+ {
+ other._value = -1;
+ }
+
+ Resource(int value, const allocator_type &allocator)
+ : _value(value), _allocator(allocator)
+ {}
+private:
+ int _value;
+ allocator_type _allocator;
+};
+
+typedef std::pair<const std::string, Resource> MapNode;
+
+typedef boost::container::scoped_allocator_adaptor<SimpleAllocator<MapNode> > MapAllocator;
+
+typedef boost::container::map<std::string, Resource, std::less<std::string>, MapAllocator> Map;
+
+int main()
+{
+ Map map1(std::less<std::string>(), SimpleAllocator<MapNode>(5));
+
+ map1.emplace("foo", 42);
+ map1.emplace("bar", 11);
+
+ //Map map2 = map1;
+ return 0;
+}


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