Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54253 - in sandbox/monotonic: boost/monotonic libs/monotonic/test/Tests
From: christian.schladetsch_at_[hidden]
Date: 2009-06-22 23:14:36


Author: cschladetsch
Date: 2009-06-22 23:14:36 EDT (Mon, 22 Jun 2009)
New Revision: 54253
URL: http://svn.boost.org/trac/boost/changeset/54253

Log:
uses boost::is_pod<T> to avoid warning in storage<>::create when using a POD type

Removed:
   sandbox/monotonic/boost/monotonic/region_allocator.hpp
Text files modified:
   sandbox/monotonic/boost/monotonic/storage.hpp | 14 +++++++++++++-
   sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj | 1 +
   sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp | 19 +++++++++++++------
   3 files changed, 27 insertions(+), 7 deletions(-)

Deleted: sandbox/monotonic/boost/monotonic/region_allocator.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/region_allocator.hpp 2009-06-22 23:14:36 EDT (Mon, 22 Jun 2009)
+++ (empty file)
@@ -1,83 +0,0 @@
-// Copyright (C) 2009 Christian Schladetsch
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_MONOTONIC_REGION_ALLOCATOR_HPP
-#define BOOST_MONOTONIC_REGION_ALLOCATOR_HPP
-
-#include <boost/monotonic/allocator_base.hpp>
-
-namespace boost
-{
- namespace monotonic
- {
- template <class Region>
- struct region_allocator<void, Region>
- {
- typedef void* pointer;
- typedef const void* const_pointer;
-
- typedef void value_type;
- template <class U>
- struct rebind
- {
- typedef region_allocator<U, Region> other;
- };
- };
-
- /// each region is distinct from other regions
- template <class T, class Region>
- struct region_allocator : allocator_base<T, region_allocator<T, Region> >
- {
- typedef allocator_base<T, region_allocator<T, Region> > Parent;
- using typename Parent::size_type;
- using typename Parent::difference_type;
- using typename Parent::pointer;
- using typename Parent::const_pointer;
- using typename Parent::reference;
- using typename Parent::const_reference;
- using typename Parent::value_type;
-
- template <class U>
- struct rebind
- {
- typedef region_allocator<U, Region> other;
- };
-
- region_allocator() throw()
- : Parent(boost::monotonic::get_region_storage<Region>()) { }
-
- public:
- //private:
- template <class Storage> struct local;
-
- region_allocator(storage_base &store) throw()
- : Parent(store) { }
-
- public:
- region_allocator(const region_allocator& alloc) throw()
- : Parent(alloc) { }
-
- template <class U, class OtherRegion>
- region_allocator(const region_allocator<U,OtherRegion> &alloc) throw()
- : Parent(alloc) { }
-
- friend bool operator==(region_allocator<T,Region> const &A, region_allocator<T,Region> const &B)
- {
- return static_cast<Parent const &>(A) == static_cast<Parent const &>(B);
- }
-
- friend bool operator!=(region_allocator<T,Region> const &A, region_allocator<T,Region> const &B)
- {
- return static_cast<Parent const &>(A) != static_cast<Parent const &>(B);
- }
- };
-
- } // namespace monotonic
-
-} // namespace boost
-
-#endif // #define BOOST_MONOTONIC_REGION_ALLOCATOR_HPP
-
-//EOF

Modified: sandbox/monotonic/boost/monotonic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/storage.hpp (original)
+++ sandbox/monotonic/boost/monotonic/storage.hpp 2009-06-22 23:14:36 EDT (Mon, 22 Jun 2009)
@@ -183,11 +183,23 @@
                         Ty &create()
                         {
                                 Ty *ptr = uninitialised_create<Ty>();
- new (ptr) Ty();
+ construct(ptr, boost::is_pod<Ty>());
                                 return *ptr;
                         }
 
                         template <class Ty>
+ void construct(Ty *ptr, const boost::true_type& /*is_pod*/)
+ {
+ // do nothing
+ }
+
+ template <class Ty>
+ void construct(Ty *ptr, const boost::false_type&)
+ {
+ new (ptr) Ty();
+ }
+
+ template <class Ty>
                         Ty &create(Ty const &X)
                         {
                                 Ty *ptr = uninitialised_create<Ty>();

Modified: sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj 2009-06-22 23:14:36 EDT (Mon, 22 Jun 2009)
@@ -115,6 +115,7 @@
                                 Name="VCCLCompilerTool"
                                 Optimization="2"
                                 EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="$(ProjectDir)/../../../..;C:\Lib\tbb21_20080605oss\include"
                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
                                 RuntimeLibrary="2"
                                 EnableFunctionLevelLinking="true"

Modified: sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp 2009-06-22 23:14:36 EDT (Mon, 22 Jun 2009)
@@ -6,7 +6,6 @@
 #include <boost/monotonic/extra/list.hpp>
 #include <boost/monotonic/extra/set.hpp>
 #include <boost/monotonic/extra/map.hpp>
-#include <boost/monotonic/region_allocator.hpp>
 
 #define BOOST_TEST_MODULE basic_test test
 #include <boost/test/unit_test.hpp>
@@ -20,13 +19,21 @@
 #endif
 
 
-BOOST_AUTO_TEST_CASE(test_region_allocator)
+struct region0 {};
+struct region1 {};
+
+BOOST_AUTO_TEST_CASE(test_regional_allocation)
 {
- typedef std::list<int, monotonic::region_allocator<int, 0> > List;
+ typedef std::list<int, monotonic::allocator<int, region0> > List0;
+ typedef std::list<int, monotonic::allocator<int, region1> > List1;
         {
- List list;
- generate_n(back_inserter(list), 10, rand);
- list.sort();
+ List0 list0;
+ generate_n(back_inserter(list0), 10, rand);
+ list0.sort();
+
+ List1 list1;
+ generate_n(back_inserter(list1), 10, rand);
+ list1.sort();
         }
 }
 


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