Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54017 - in trunk: boost/flyweight/detail libs/flyweight/doc libs/flyweight/test
From: joaquin_at_[hidden]
Date: 2009-06-17 14:54:36


Author: joaquin
Date: 2009-06-17 14:54:33 EDT (Wed, 17 Jun 2009)
New Revision: 54017
URL: http://svn.boost.org/trac/boost/changeset/54017

Log:
fixed bug occurring when a user exception is thrown in some points of flyweight construction
Removed:
   trunk/boost/flyweight/detail/handle_factory_adaptor.hpp
Text files modified:
   trunk/boost/flyweight/detail/flyweight_core.hpp | 48 ++++++++++++++++++---------------------
   trunk/libs/flyweight/doc/release_notes.html | 11 ++++++++
   trunk/libs/flyweight/test/heavy_objects.hpp | 23 +++++++++++++++++-
   trunk/libs/flyweight/test/test_basic_template.hpp | 17 +++++++++++++
   4 files changed, 69 insertions(+), 30 deletions(-)

Modified: trunk/boost/flyweight/detail/flyweight_core.hpp
==============================================================================
--- trunk/boost/flyweight/detail/flyweight_core.hpp (original)
+++ trunk/boost/flyweight/detail/flyweight_core.hpp 2009-06-17 14:54:33 EDT (Wed, 17 Jun 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -16,7 +16,6 @@
 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
 #include <boost/detail/no_exceptions_support.hpp>
 #include <boost/detail/workaround.hpp>
-#include <boost/flyweight/detail/handle_factory_adaptor.hpp>
 #include <boost/mpl/apply.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 
@@ -79,34 +78,31 @@
 class flyweight_core
 {
 public:
- typedef typename ValuePolicy::key_type key_type;
- typedef typename ValuePolicy::value_type value_type;
- typedef typename ValuePolicy::rep_type rep_type;
+ typedef typename ValuePolicy::key_type key_type;
+ typedef typename ValuePolicy::value_type value_type;
+ typedef typename ValuePolicy::rep_type rep_type;
   typedef typename mpl::apply2<
     typename TrackingPolicy::entry_type,
     rep_type,
     key_type
- >::type entry_type;
+ >::type entry_type;
   typedef typename mpl::apply2<
     FactorySpecifier,
     entry_type,
     key_type
- >::type base_factory_type;
+ >::type factory_type;
+ typedef typename factory_type::handle_type base_handle_type;
   typedef typename mpl::apply2<
     typename TrackingPolicy::handle_type,
- typename base_factory_type::handle_type,
+ base_handle_type,
     flyweight_core_tracking_helper<
       ValuePolicy,Tag,TrackingPolicy,
       FactorySpecifier,LockingPolicy,
       HolderSpecifier
>
- >::type handle_type;
- typedef handle_factory_adaptor<
- base_factory_type,
- handle_type,entry_type
- > factory_type;
- typedef typename LockingPolicy::mutex_type mutex_type;
- typedef typename LockingPolicy::lock_type lock_type;
+ >::type handle_type;
+ typedef typename LockingPolicy::mutex_type mutex_type;
+ typedef typename LockingPolicy::lock_type lock_type;
 
   static bool init()
   {
@@ -132,7 +128,7 @@
   static handle_type insert(const value_type& x){return insert_value(x);}
   static handle_type insert(value_type& x){return insert_value(x);}
 
- static const entry_type& entry(const handle_type& h)
+ static const entry_type& entry(const base_handle_type& h)
   {
     return factory().entry(h);
   }
@@ -158,7 +154,7 @@
   }
 
 private:
- struct holder_arg
+ struct holder_arg
   {
     factory_type factory;
     mutex_type mutex;
@@ -166,14 +162,14 @@
   typedef typename mpl::apply1<
     HolderSpecifier,
     holder_arg
- >::type holder_type;
+ >::type holder_type;
 
   static handle_type insert_rep(const rep_type& x)
   {
     init();
- entry_type e(x);
- lock_type lock(mutex());
- handle_type h(factory().insert(e));
+ entry_type e(x);
+ lock_type lock(mutex());
+ base_handle_type h(factory().insert(e));
     BOOST_TRY{
       ValuePolicy::construct_value(
         static_cast<const rep_type&>(entry(h)));
@@ -183,15 +179,15 @@
       BOOST_RETHROW;
     }
     BOOST_CATCH_END
- return h;
+ return static_cast<handle_type>(h);
   }
 
   static handle_type insert_value(const value_type& x)
   {
     init();
- entry_type e=entry_type(rep_type(x));
- lock_type lock(mutex());
- handle_type h(factory().insert(e));
+ entry_type e((rep_type(x)));
+ lock_type lock(mutex());
+ base_handle_type h(factory().insert(e));
     BOOST_TRY{
       ValuePolicy::copy_value(
         static_cast<const rep_type&>(entry(h)));
@@ -201,7 +197,7 @@
       BOOST_RETHROW;
     }
     BOOST_CATCH_END
- return h;
+ return static_cast<handle_type>(h);
   }
 
   static bool static_initializer;

Deleted: trunk/boost/flyweight/detail/handle_factory_adaptor.hpp
==============================================================================
--- trunk/boost/flyweight/detail/handle_factory_adaptor.hpp 2009-06-17 14:54:33 EDT (Wed, 17 Jun 2009)
+++ (empty file)
@@ -1,48 +0,0 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
- * 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)
- *
- * See http://www.boost.org/libs/flyweight for library home page.
- */
-
-#ifndef BOOST_FLYWEIGHT_DETAIL_HANDLE_FACTORY_ADAPTOR_HPP
-#define BOOST_FLYWEIGHT_DETAIL_HANDLE_FACTORY_ADAPTOR_HPP
-
-#if defined(_MSC_VER)&&(_MSC_VER>=1200)
-#pragma once
-#endif
-
-/* Given a Factory and a Handle type constructible from and implicitly
- * convertible to Factory::handle_type, handle_factory_adaptor
- * adapts Factory to present Handle as the associated handle_type.
- */
-
-namespace boost{
-
-namespace flyweights{
-
-namespace detail{
-
-template<typename Factory,typename Handle,typename Entry>
-struct handle_factory_adaptor:Factory
-{
-public:
- typedef Handle handle_type;
-
- handle_type insert(const Entry& x)
- {
- return static_cast<handle_type>(base().insert(x));
- }
-
-private:
- Factory& base(){return *this;}
-};
-
-} /* namespace flyweights::detail */
-
-} /* namespace flyweights */
-
-} /* namespace boost */
-
-#endif

Modified: trunk/libs/flyweight/doc/release_notes.html
==============================================================================
--- trunk/libs/flyweight/doc/release_notes.html (original)
+++ trunk/libs/flyweight/doc/release_notes.html 2009-06-17 14:54:33 EDT (Wed, 17 Jun 2009)
@@ -31,10 +31,19 @@
 <h2>Contents</h2>
 
 <ul>
+ <li>Boost 1.40 release</li>
   <li>Boost 1.39 release</li>
   <li>Boost 1.38 release</li>
 </ul>
 
+<h2><a name="boost_1_40">Boost 1.40 release</a></h2>
+
+<p>
+<ul>
+ <li>Maintenance fixes.</li>
+</ul>
+</p>
+
 <h2><a name="boost_1_39">Boost 1.39 release</a></h2>
 
 <p>
@@ -69,7 +78,7 @@
 
 <br>
 
-<p>Revised April 7th 2009</p>
+<p>Revised April 25th 2009</p>
 
 <p>&copy; Copyright 2006-2009 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
 Distributed under the Boost Software

Modified: trunk/libs/flyweight/test/heavy_objects.hpp
==============================================================================
--- trunk/libs/flyweight/test/heavy_objects.hpp (original)
+++ trunk/libs/flyweight/test/heavy_objects.hpp 2009-06-17 14:54:33 EDT (Wed, 17 Jun 2009)
@@ -1,6 +1,6 @@
-/* Boost.Flyweight basic test template.
+/* Classes for Boost.Flyweight key-value tests.
  *
- * Copyright 2006-2008 Joaquin M Lopez Munoz.
+ * Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -15,6 +15,7 @@
 #pragma once
 #endif
 
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
 #include <boost/noncopyable.hpp>
 #include <iosfwd>
 #include <string>
@@ -84,4 +85,22 @@
   int n;
 };
 
+#if !defined(BOOST_NO_EXCEPTIONS)
+struct throwing_value_exception{};
+
+struct throwing_value
+{
+ throwing_value():n(0){}
+ throwing_value(const throwing_value&){throw throwing_value_exception();}
+ throwing_value(int){throw throwing_value_exception();}
+
+ int n;
+};
+
+struct from_throwing_value_to_int
+{
+ const int& operator()(const throwing_value& x)const{return x.n;}
+};
+#endif
+
 #endif

Modified: trunk/libs/flyweight/test/test_basic_template.hpp
==============================================================================
--- trunk/libs/flyweight/test/test_basic_template.hpp (original)
+++ trunk/libs/flyweight/test/test_basic_template.hpp 2009-06-17 14:54:33 EDT (Wed, 17 Jun 2009)
@@ -1,6 +1,6 @@
 /* Boost.Flyweight basic test template.
  *
- * Copyright 2006-2008 Joaquin M Lopez Munoz.
+ * Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -225,6 +225,21 @@
 
   test_basic_comparison_template<texture_flyweight,texture_flyweight>(
     &textures[0],&textures[0]+LENGTHOF(textures)-1,&textures[1]);
+
+#if !defined(BOOST_NO_EXCEPTIONS)
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<int,throwing_value,from_throwing_value_to_int>
+ >::type throwing_flyweight;
+
+ try{
+ throwing_flyweight fw(0);
+ }catch(const throwing_value_exception&){}
+ try{
+ throwing_flyweight fw((throwing_value()));
+ }catch(const throwing_value_exception&){}
+#endif
+
 }
 
 #undef LENGTHOF


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