|
Boost-Commit : |
From: joaquin_at_[hidden]
Date: 2008-09-01 11:52:47
Author: joaquin
Date: 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
New Revision: 48514
URL: http://svn.boost.org/trac/boost/changeset/48514
Log:
post-review version
Text files modified:
sandbox/flyweight/boost/flyweight.hpp | 2
sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp | 8
sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp | 2
sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp | 153 +++++++++++++++++++++++-----------
sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp | 2
sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp | 2
sandbox/flyweight/boost/flyweight/detail/process_id.hpp | 2
sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp | 2
sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp | 44 ++++++---
sandbox/flyweight/boost/flyweight/factory_tag.hpp | 2
sandbox/flyweight/boost/flyweight/flyweight.hpp | 63 +++++++++----
sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/hashed_factory.hpp | 37 ++------
sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp | 4
sandbox/flyweight/boost/flyweight/holder_tag.hpp | 2
sandbox/flyweight/boost/flyweight/intermodule_holder.hpp | 2
sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/locking_tag.hpp | 2
sandbox/flyweight/boost/flyweight/no_locking.hpp | 2
sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/no_tracking.hpp | 4
sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/refcounted.hpp | 43 ++++++--
sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/serialize.hpp | 20 ++--
sandbox/flyweight/boost/flyweight/set_factory.hpp | 31 +-----
sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp | 4
sandbox/flyweight/boost/flyweight/simple_locking.hpp | 2
sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/static_holder.hpp | 2
sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp | 2
sandbox/flyweight/boost/flyweight/tag.hpp | 2
sandbox/flyweight/boost/flyweight/tracking_tag.hpp | 2
sandbox/flyweight/libs/flyweight/doc/acknowledgements.html | 31 ++++--
sandbox/flyweight/libs/flyweight/doc/examples.html | 111 +++++++++++++++++++-----
sandbox/flyweight/libs/flyweight/doc/future_work.html | 42 ++++++--
sandbox/flyweight/libs/flyweight/doc/index.html | 9 -
sandbox/flyweight/libs/flyweight/doc/reference/factories.html | 72 ++++++++-------
sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html | 178 ++++++++++++++++++++++++++-------------
sandbox/flyweight/libs/flyweight/doc/reference/holders.html | 16 +-
sandbox/flyweight/libs/flyweight/doc/reference/index.html | 17 ++-
sandbox/flyweight/libs/flyweight/doc/reference/locking.html | 22 ++--
sandbox/flyweight/libs/flyweight/doc/reference/tags.html | 22 ++--
sandbox/flyweight/libs/flyweight/doc/reference/tracking.html | 32 +++---
sandbox/flyweight/libs/flyweight/doc/tests.html | 22 ++--
sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html | 20 ++--
sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html | 111 ++++++++++++++++++------
sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html | 96 +++++++++++---------
sandbox/flyweight/libs/flyweight/doc/tutorial/index.html | 30 +++++-
sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html | 25 ++--
sandbox/flyweight/libs/flyweight/doc/tutorial/technical.html | 61 ++++++++++---
sandbox/flyweight/libs/flyweight/example/Jamfile.v2 | 13 ++
sandbox/flyweight/libs/flyweight/example/basic.cpp | 2
sandbox/flyweight/libs/flyweight/example/composite.cpp | 2
sandbox/flyweight/libs/flyweight/example/custom_factory.cpp | 20 ++--
sandbox/flyweight/libs/flyweight/example/html.cpp | 2
sandbox/flyweight/libs/flyweight/example/perf.cpp | 150 ++++++++++++++++++---------------
sandbox/flyweight/libs/flyweight/example/serialization.cpp | 2
sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp | 2
sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_all_main.cpp | 6 -
sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp | 23 ++--
sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_basic.cpp | 25 +---
sandbox/flyweight/libs/flyweight/test/test_basic.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp | 122 +++++++++++++++++---------
sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp | 16 +-
sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_init.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_init.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_init_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp | 4
sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_multictor.cpp | 3
sandbox/flyweight/libs/flyweight/test/test_multictor.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp | 4
sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp | 4
sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_serialization.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_serialization.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp | 2
sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp | 25 +---
sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp | 2
sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp | 2
94 files changed, 1110 insertions(+), 737 deletions(-)
Modified: sandbox/flyweight/boost/flyweight.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight.hpp (original)
+++ sandbox/flyweight/boost/flyweight.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp (original)
+++ sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -43,7 +43,7 @@
cont.erase(h);
}
- const entry_type& entry(handle_type h){return *h;}
+ static const entry_type& entry(handle_type h){return *h;}
private:
Container cont;
@@ -61,11 +61,11 @@
>
struct assoc_container_factory:factory_marker
{
- template<typename Entry,typename Value>
+ template<typename Entry,typename Key>
struct apply
{
typedef assoc_container_factory_class<
- typename mpl::apply2<ContainerSpecifier,Entry,Value>::type
+ typename mpl::apply2<ContainerSpecifier,Entry,Key>::type
> type;
};
};
Modified: sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -14,10 +14,12 @@
#endif
#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/flyweight/detail/prevent_eti.hpp>
+#include <boost/flyweight/detail/has_static_entry.hpp>
#include <boost/mpl/apply.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(push)
@@ -25,8 +27,8 @@
#endif
/* flyweight_core provides the inner implementation of flyweight<> by
- * weaving together a flyweight factory, a holder for the factory,
- * a tracking policy and a locking policy.
+ * weaving together a value policy, a flyweight factory, a holder for the
+ * factory,a tracking policy and a locking policy.
*/
namespace boost{
@@ -36,20 +38,20 @@
namespace detail{
template<
- typename Value,typename Tag,typename TrackingPolicy,
+ typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
class flyweight_core;
template<
- typename Value,typename Tag,typename TrackingPolicy,
+ typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
struct flyweight_core_tracking_helper
{
private:
typedef flyweight_core<
- Value,Tag,TrackingPolicy,
+ ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,
HolderSpecifier
> core;
@@ -59,7 +61,7 @@
public:
static const entry_type& entry(const handle_type& h)
{
- return core::factory().entry(h);
+ return core::entry(h);
}
template<typename Checker>
@@ -72,39 +74,34 @@
};
template<
- typename Value,typename Tag,typename TrackingPolicy,
+ typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
class flyweight_core
{
public:
- typedef typename detail::prevent_eti<
- TrackingPolicy,
- typename mpl::apply1<
- typename TrackingPolicy::entry_type,
- Value
- >::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;
- typedef typename detail::prevent_eti<
+ typedef typename mpl::apply2<
FactorySpecifier,
- typename mpl::apply2<
- FactorySpecifier,
- entry_type,
- Value
- >::type
+ entry_type,
+ key_type
>::type base_factory_type;
- typedef typename detail::prevent_eti<
- TrackingPolicy,
- typename mpl::apply2<
- typename TrackingPolicy::handle_type,
- typename base_factory_type::handle_type,
- flyweight_core_tracking_helper<
- Value,Tag,TrackingPolicy,
- FactorySpecifier,LockingPolicy,
- HolderSpecifier
- >
- >::type
- >::type handle_type;
+ typedef typename mpl::apply2<
+ typename TrackingPolicy::handle_type,
+ typename base_factory_type::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
@@ -114,15 +111,32 @@
static bool init(){return &(factory())!=0;}
- static handle_type insert(const Value& x)
+ /* insert overloads*/
+
+#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME static handle_type insert
+#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
+{ \
+ return insert_rep(rep_type(BOOST_PP_ENUM_PARAMS(n,t))); \
+}
+#include <boost/flyweight/detail/perfect_fwd.hpp>
+
+ 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)
+ {
+ return entry_impl(
+ h,detail::has_static_entry<base_factory_type,entry_type>());
+ }
+
+ static const value_type& value(const handle_type& h)
{
- lock_type lock(mutex());
- return handle_type(factory().insert(entry_type(x)));
+ return static_cast<const rep_type&>(entry(h));
}
-
- static const Value& value(const handle_type& h)
+
+ static const key_type& key(const handle_type& h)
{
- return factory().entry(h);
+ return static_cast<const rep_type&>(entry(h));
}
static factory_type& factory()
@@ -138,31 +152,72 @@
}
private:
- struct holder_arg
+ struct holder_arg
{
factory_type factory;
mutex_type mutex;
};
- typedef typename detail::prevent_eti<
+ typedef typename mpl::apply1<
HolderSpecifier,
- typename mpl::apply1<
- HolderSpecifier,
- holder_arg
- >::type
- >::type holder_type;
+ holder_arg
+ >::type holder_type;
+
+ static const entry_type& entry_impl(const handle_type& h,boost::mpl::true_)
+ {
+ return factory_type::entry(h);
+ }
+
+ static const entry_type& entry_impl(const handle_type& h,boost::mpl::false_)
+ {
+ return factory().entry(h);
+ }
+
+ static handle_type insert_rep(const rep_type& x)
+ {
+ entry_type e(x);
+ lock_type lock(mutex());
+ handle_type h(factory().insert(e));
+ BOOST_TRY{
+ ValuePolicy::construct_value(
+ static_cast<const rep_type&>(entry(h)));
+ }
+ BOOST_CATCH(...){
+ factory().erase(h);
+ BOOST_RETHROW;
+ }
+ BOOST_CATCH_END
+ return h;
+ }
+
+ static handle_type insert_value(const value_type& x)
+ {
+ entry_type e=entry_type(rep_type(x));
+ lock_type lock(mutex());
+ handle_type h(factory().insert(e));
+ BOOST_TRY{
+ ValuePolicy::copy_value(
+ static_cast<const rep_type&>(entry(h)));
+ }
+ BOOST_CATCH(...){
+ factory().erase(h);
+ BOOST_RETHROW;
+ }
+ BOOST_CATCH_END
+ return h;
+ }
static bool static_force_holder_get;
};
template<
- typename Value,typename Tag,typename TrackingPolicy,
+ typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
bool flyweight_core<
- Value,Tag,TrackingPolicy,
+ ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::static_force_holder_get=
&(flyweight_core<
- Value,Tag,TrackingPolicy,
+ ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::holder_type::get())!=0;
} /* namespace flyweights::detail */
Modified: sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/detail/process_id.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/process_id.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/process_id.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp (original)
+++ sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -20,6 +20,7 @@
#include <boost/noncopyable.hpp>
#include <boost/serialization/extended_type_info.hpp>
#include <boost/shared_ptr.hpp>
+#include <vector>
namespace boost{
@@ -27,7 +28,7 @@
namespace detail{
-/* The serialization helper for flyweight<T> maps numerical IDs to
+/* The serialization helpers for flyweight<T> map numerical IDs to
* flyweight exemplars --an exemplar is the flyweight object
* associated to a given value that appears first on the serialization
* stream, so that subsequent equivalent flyweight objects will be made
@@ -43,7 +44,7 @@
};
template<typename Flyweight>
-class serialization_helper:private noncopyable
+class save_helper:private noncopyable
{
typedef multi_index::multi_index_container<
Flyweight,
@@ -59,36 +60,51 @@
size_type size()const{return t.size();}
- Flyweight operator[](size_type n)const{return t[n];}
-
size_type find(const Flyweight& x)const
{
return multi_index::project<0>(t,multi_index::get<1>(t).find(&x.get()))
-t.begin();
}
- bool push_back(const Flyweight& x){return t.push_back(x).second;}
+ void push_back(const Flyweight& x){t.push_back(x);}
private:
table t;
};
-template<typename Flyweight,class Archive>
-serialization_helper<Flyweight>& get_serialization_helper(
- Archive & ar
- BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+template<typename Flyweight>
+class load_helper:private noncopyable
{
- typedef serialization_helper<Flyweight> helper;
+ typedef std::vector<Flyweight> table;
+
+public:
+
+ typedef typename table::size_type size_type;
+
+ size_type size()const{return t.size();}
+ Flyweight operator[](size_type n)const{return t[n];}
+
+ void push_back(const Flyweight& x){t.push_back(x);}
+
+private:
+ table t;
+};
+
+template<typename Helper,class Archive>
+Helper& get_serialization_helper(
+ Archive& ar
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Helper))
+{
serialization::extended_type_info* eti=
- serialization::type_info_implementation<helper>::type::get_instance();
+ serialization::type_info_implementation<Helper>::type::get_instance();
shared_ptr<void> sph;
ar.lookup_helper(eti,sph);
if(!sph.get()){
- sph=shared_ptr<helper>(new helper);
+ sph=shared_ptr<Helper>(new Helper);
ar.insert_helper(eti, sph);
}
- return *static_cast<helper*>(sph.get());
+ return *static_cast<Helper*>(sph.get());
}
} /* namespace flyweights::detail */
Modified: sandbox/flyweight/boost/flyweight/factory_tag.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/factory_tag.hpp (original)
+++ sandbox/flyweight/boost/flyweight/factory_tag.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/flyweight.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/flyweight.hpp (original)
+++ sandbox/flyweight/boost/flyweight/flyweight.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Flyweight class.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -18,9 +18,8 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/detail/workaround.hpp>
+#include <boost/flyweight/detail/default_value_policy.hpp>
#include <boost/flyweight/detail/flyweight_core.hpp>
-#include <boost/flyweight/detail/prevent_eti.hpp>
-#include <boost/flyweight/detail/template_ctors_def.hpp>
#include <boost/flyweight/factory_tag.hpp>
#include <boost/flyweight/flyweight_fwd.hpp>
#include <boost/flyweight/locking_tag.hpp>
@@ -31,11 +30,14 @@
#include <boost/flyweight/refcounted_fwd.hpp>
#include <boost/flyweight/tag.hpp>
#include <boost/flyweight/tracking_tag.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/or.hpp>
#include <boost/parameter/binding.hpp>
-#include <boost/static_assert.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/type_traits/is_same.hpp>
+#include <boost/utility/swap.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(push)
@@ -63,6 +65,11 @@
class flyweight
{
private:
+ typedef typename mpl::if_<
+ detail::is_value<T>,
+ T,
+ detail::default_value_policy<T>
+ >::type value_policy;
typedef parameter::parameters<
parameter::optional<
parameter::deduced<tag<> >,
@@ -127,21 +134,25 @@
unmatched_args,detail::unmatched_arg,
detail::unmatched_arg
>::type unmatched_arg_detected;
- BOOST_STATIC_ASSERT((
- /* You have passed a type in the specification of a flyweight type that
- * could not be interpreted as a valid argument.
- */
- is_same<unmatched_arg_detected,detail::unmatched_arg>::value));
+
+ /* You have passed a type in the specification of a flyweight type that
+ * could not be interpreted as a valid argument.
+ */
+ BOOST_MPL_ASSERT_MSG(
+ (is_same<unmatched_arg_detected,detail::unmatched_arg>::value),
+ INVALID_ARGUMENT_TO_FLYWEIGHT,
+ (flyweight));
typedef detail::flyweight_core<
- T,tag_type,tracking_policy,
+ value_policy,tag_type,tracking_policy,
factory_specifier,locking_policy,
holder_specifier
> core;
typedef typename core::handle_type handle_type;
public:
- typedef T value_type;
+ typedef typename value_policy::key_type key_type;
+ typedef typename value_policy::value_type value_type;
/* static data initialization */
@@ -157,19 +168,25 @@
/* construct/copy/destroy */
- flyweight():h(core::insert(T())){}
+ flyweight():h(core::insert(key_type())){}
flyweight(const flyweight& x):h(x.h){}
flyweight(flyweight& x):h(x.h){}
- BOOST_FLYWEIGHT_CTORS
-
- flyweight& operator=(const T& t){return operator=(flyweight(t));}
+ /* template ctors */
+
+#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit flyweight
+#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
+ :h(core::insert(BOOST_PP_ENUM_PARAMS(n,t))){}
+#include <boost/flyweight/detail/perfect_fwd.hpp>
+
+ flyweight& operator=(const flyweight x){h=x.h;return *this;}
+ flyweight& operator=(const value_type& x){return operator=(flyweight(x));}
/* convertibility to underlying type */
- const T& get()const{return core::value(h);}
-
- operator const T&()const{return get();}
+ const key_type& get_key()const{return core::key(h);}
+ const value_type& get()const{return core::value(h);}
+ operator const value_type&()const{return get();}
/* exact type equality */
@@ -180,7 +197,7 @@
/* modifiers */
- void swap(flyweight& x){std::swap(h,x.h);}
+ void swap(flyweight& x){boost::swap(h,x.h);}
private:
handle_type h;
@@ -350,7 +367,12 @@
BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& in,
flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x)
{
- T t(x.get()); /* T need not be default ctble but must be copy ctble */
+ typedef typename flyweight<
+ T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)
+ >::value_type value_type;
+
+ /* value_type need not be default ctble but must be copy ctble */
+ value_type t(x.get());
in>>t;
x=t;
return in;
@@ -363,7 +385,6 @@
#undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS
#undef BOOST_FLYWEIGHT_TEMPL_ARGS
#undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS
-#include <boost/flyweight/detail/template_ctors_undef.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(pop)
Modified: sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/hashed_factory.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/hashed_factory.hpp (original)
+++ sandbox/flyweight/boost/flyweight/hashed_factory.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -31,7 +31,7 @@
namespace flyweights{
template<
- typename Entry,typename Value,
+ typename Entry,typename Key,
typename Hash,typename Pred,typename Allocator
>
class hashed_factory_class:public factory_marker
@@ -42,12 +42,12 @@
multi_index::identity<Entry>,
typename boost::mpl::if_<
mpl::is_na<Hash>,
- hash<Value>,
+ hash<Key>,
Hash
>::type,
typename boost::mpl::if_<
mpl::is_na<Pred>,
- std::equal_to<Value>,
+ std::equal_to<Key>,
Pred
>::type
>
@@ -77,7 +77,7 @@
cont.erase(cont.iterator_to(*h));
}
- const Entry& entry(handle_type h){return *h;}
+ static const Entry& entry(handle_type h){return *h;}
private:
container_type cont;
@@ -85,43 +85,24 @@
public:
typedef hashed_factory_class type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(
- 5,hashed_factory_class,(Entry,Value,Hash,Pred,Allocator))
+ 5,hashed_factory_class,(Entry,Key,Hash,Pred,Allocator))
};
/* hashed_factory_class specifier */
-namespace detail{
-
-/* MSVC 6.0 gets choked on MPL apply code if this level of indirection
- * is not used.
- */
-
-template<
- typename Entry,typename Value,typename Hash,typename Pred,typename Allocator
->
-struct hashed_factory_class_fwd
-{
- typedef hashed_factory_class<Entry,Value,Hash,Pred,Allocator> type;
-
- BOOST_MPL_AUX_LAMBDA_SUPPORT(
- 5,hashed_factory_class_fwd,(Entry,Value,Hash,Pred,Allocator))
-};
-
-} /* namespace flyweights::detail */
-
template<
typename Hash,typename Pred,typename Allocator
BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
>
struct hashed_factory:factory_marker
{
- template<typename Entry,typename Value>
+ template<typename Entry,typename Key>
struct apply:
mpl::apply2<
- detail::hashed_factory_class_fwd<
+ hashed_factory_class<
boost::mpl::_1,boost::mpl::_2,Hash,Pred,Allocator
>,
- Entry,Value
+ Entry,Key
>
{};
};
Modified: sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -22,7 +22,7 @@
namespace flyweights{
template<
- typename Entry,typename Value,
+ typename Entry,typename Key,
typename Hash=mpl::na,typename Pred=mpl::na,typename Allocator=mpl::na
>
class hashed_factory_class;
Modified: sandbox/flyweight/boost/flyweight/holder_tag.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/holder_tag.hpp (original)
+++ sandbox/flyweight/boost/flyweight/holder_tag.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/intermodule_holder.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/intermodule_holder.hpp (original)
+++ sandbox/flyweight/boost/flyweight/intermodule_holder.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/locking_tag.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/locking_tag.hpp (original)
+++ sandbox/flyweight/boost/flyweight/locking_tag.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/no_locking.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/no_locking.hpp (original)
+++ sandbox/flyweight/boost/flyweight/no_locking.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/no_tracking.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/no_tracking.hpp (original)
+++ sandbox/flyweight/boost/flyweight/no_tracking.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -28,7 +28,7 @@
{
struct entry_type
{
- template<typename Value>
+ template<typename Value,typename Key>
struct apply{typedef Value type;};
};
Modified: sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/refcounted.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/refcounted.hpp (original)
+++ sandbox/flyweight/boost/flyweight/refcounted.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -15,6 +15,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
+#include <boost/assert.hpp>
#include <boost/detail/atomic_count.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/flyweight/refcounted_fwd.hpp>
@@ -31,7 +32,7 @@
namespace detail{
-template<typename Value>
+template<typename Value,typename Key>
class refcounted_value
{
public:
@@ -42,7 +43,18 @@
refcounted_value(const refcounted_value& r):
x(r.x),ref(0)
{}
-
+
+ ~refcounted_value()
+ {
+ /* count()!=0 most likely indicates that the flyweight factory
+ * has been destructed before some of the flyweight objects using
+ * it. Check for static initialization order problems with this
+ * flyweight type.
+ */
+
+ BOOST_ASSERT(count()==0);
+ }
+
refcounted_value& operator=(const refcounted_value& r)
{
x=r.x;
@@ -50,6 +62,7 @@
}
operator const Value&()const{return x;}
+ operator const Key&()const{return x;}
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
private:
@@ -59,8 +72,8 @@
long count()const{return ref;}
void add_ref()const{++ref;}
bool release()const{return (--ref==0);}
-
-private:
+
+private:
Value x;
mutable boost::detail::atomic_count ref;
};
@@ -77,15 +90,14 @@
refcounted_handle(const refcounted_handle& x):h(x.h)
{
TrackingHelper::entry(*this).add_ref();
- }
+ }
- refcounted_handle& operator=(const refcounted_handle& x)
+ refcounted_handle& operator=(refcounted_handle x)
{
- refcounted_handle tmp(x);
- std::swap(h,tmp.h);
+ swap(*this,x);
return *this;
}
-
+
~refcounted_handle()
{
if(TrackingHelper::entry(*this).release()){
@@ -94,7 +106,12 @@
}
operator const Handle&()const{return h;}
-
+
+ friend void swap(refcounted_handle& x, refcounted_handle& y)
+ {
+ std::swap(x.h,y.h);
+ }
+
private:
static bool check_erase(const refcounted_handle& x)
{
@@ -110,10 +127,10 @@
{
struct entry_type
{
- template<typename Value>
+ template<typename Value,typename Key>
struct apply
{
- typedef detail::refcounted_value<Value> type;
+ typedef detail::refcounted_value<Value,Key> type;
};
};
Modified: sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/serialize.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/serialize.hpp (original)
+++ sandbox/flyweight/boost/flyweight/serialize.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -48,13 +48,12 @@
Archive& ar,const ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f,
const unsigned int version)
{
- typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight;
- typedef ::boost::flyweights::detail::serialization_helper<
- flyweight> helper;
- typedef typename helper::size_type size_type;
+ typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight;
+ typedef ::boost::flyweights::detail::save_helper<flyweight> helper;
+ typedef typename helper::size_type size_type;
helper& hlp=
- ::boost::flyweights::detail::get_serialization_helper<flyweight>(ar);
+ ::boost::flyweights::detail::get_serialization_helper<helper>(ar);
size_type n=hlp.find(f);
ar<<make_nvp("item",n);
@@ -72,13 +71,12 @@
Archive& ar,::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f,
const unsigned int version)
{
- typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight;
- typedef ::boost::flyweights::detail::serialization_helper<
- flyweight> helper;
- typedef typename helper::size_type size_type;
+ typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight;
+ typedef ::boost::flyweights::detail::load_helper<flyweight> helper;
+ typedef typename helper::size_type size_type;
helper& hlp=
- ::boost::flyweights::detail::get_serialization_helper<flyweight>(ar);
+ ::boost::flyweights::detail::get_serialization_helper<helper>(ar);
size_type n=0;
ar>>make_nvp("item",n);
Modified: sandbox/flyweight/boost/flyweight/set_factory.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/set_factory.hpp (original)
+++ sandbox/flyweight/boost/flyweight/set_factory.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -30,7 +30,7 @@
namespace flyweights{
template<
- typename Entry,typename Value,
+ typename Entry,typename Key,
typename Compare,typename Allocator
>
class set_factory_class:
@@ -39,7 +39,7 @@
Entry,
typename boost::mpl::if_<
mpl::is_na<Compare>,
- std::less<Value>,
+ std::less<Key>,
Compare
>::type,
typename boost::mpl::if_<
@@ -53,41 +53,24 @@
public:
typedef set_factory_class type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(
- 4,set_factory_class,(Entry,Value,Compare,Allocator))
+ 4,set_factory_class,(Entry,Key,Compare,Allocator))
};
/* set_factory_class specifier */
-namespace detail{
-
-/* MSVC 6.0 gets choked on MPL apply code if this level of indirection
- * is not used.
- */
-
-template<typename Entry,typename Value,typename Compare,typename Allocator>
-struct set_factory_class_fwd
-{
- typedef set_factory_class<Entry,Value,Compare,Allocator> type;
-
- BOOST_MPL_AUX_LAMBDA_SUPPORT(
- 4,set_factory_class_fwd,(Entry,Value,Compare,Allocator))
-};
-
-} /* namespace flyweights::detail */
-
template<
typename Compare,typename Allocator
BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
>
struct set_factory:factory_marker
{
- template<typename Entry,typename Value>
+ template<typename Entry,typename Key>
struct apply:
mpl::apply2<
- detail::set_factory_class_fwd<
+ set_factory_class<
boost::mpl::_1,boost::mpl::_2,Compare,Allocator
>,
- Entry,Value
+ Entry,Key
>
{};
};
Modified: sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
@@ -22,7 +22,7 @@
namespace flyweights{
template<
- typename Entry,typename Value,
+ typename Entry,typename Key,
typename Compare=mpl::na,typename Allocator=mpl::na
>
class set_factory_class;
Modified: sandbox/flyweight/boost/flyweight/simple_locking.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/simple_locking.hpp (original)
+++ sandbox/flyweight/boost/flyweight/simple_locking.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/static_holder.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/static_holder.hpp (original)
+++ sandbox/flyweight/boost/flyweight/static_holder.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp (original)
+++ sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/tag.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/tag.hpp (original)
+++ sandbox/flyweight/boost/flyweight/tag.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/boost/flyweight/tracking_tag.hpp
==============================================================================
--- sandbox/flyweight/boost/flyweight/tracking_tag.hpp (original)
+++ sandbox/flyweight/boost/flyweight/tracking_tag.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2007 Joaquín M López Muñoz.
+/* 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)
Modified: sandbox/flyweight/libs/flyweight/doc/acknowledgements.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/acknowledgements.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/acknowledgements.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -6,16 +6,16 @@
<title>Boost.Flyweight Documentation - Acknowledgements</title>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="start" href="index.html">
-<link rel="prev" href="review_notes.html">
+<link rel="prev" href="release_notes.html">
<link rel="up" href="index.html">
</head>
<body>
-<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Acknowledgements</h1>
-<div class="prev_link"><a href="review_notes.html"><img src="prev.gif" alt="review notes" border="0"><br>
-Review_notes
+<div class="prev_link"><a href="release_notes.html"><img src="prev.gif" alt="release notes" border="0"><br>
+Release notes
</a></div>
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
@@ -25,8 +25,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<p>
The following people have provided valuable feedback and suggestions during the
development of the library: Ion Gaztañaga, Janek Kozicki, Tobias Schwinger,
@@ -35,6 +33,16 @@
</p>
<p>
+The acceptance review of Boost.Flyweight took place between January 21st
+and February 3rd 2008. Many thanks to Ion Gaztañaga, the stalwart review manager,
+and to all the reviewers: Alberto Ganesh Barbati, Tim Blechmann,
+Vicente Juan Botet Escriba, Matías Capeletto, Neil Hunt, Marcus Lindblom,
+John Reid, David Sankel, Kevin Sopp, John Torjo, Markus Werle. Alberto identified
+important limitations of the initial design, which led to the
+introduction of key-value flyweights.
+</p>
+
+<p>
Boost.Flyweight relies on the
<a href="../../mpl/doc/index.html">Boost MPL Library</a> from
Aleksey Gurtovoy. The
@@ -50,10 +58,15 @@
from Robert Ramey.
</p>
+<p>
+This work is dedicated to Jorge López, in the hope that past
+dire straits gentler oceans will lie.
+</p>
+
<hr>
-<div class="prev_link"><a href="review_notes.html"><img src="prev.gif" alt="review notes" border="0"><br>
-Review_notes
+<div class="prev_link"><a href="release_notes.html"><img src="prev.gif" alt="release notes" border="0"><br>
+Release notes
</a></div>
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
@@ -63,7 +76,7 @@
<br>
-<p>Revised January 16th 2008</p>
+<p>Revised September 1st 2008</p>
<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
Modified: sandbox/flyweight/libs/flyweight/doc/examples.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/examples.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/examples.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -6,39 +6,39 @@
<title>Boost.Flyweight Documentation - Examples</title>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="start" href="index.html">
-<link rel="prev" href="reference/tracking.html">
+<link rel="prev" href="performance.html">
<link rel="up" href="index.html">
-<link rel="next" href="future_work.html">
+<link rel="next" href="tests.html">
</head>
<body>
-<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Examples</h1>
-<div class="prev_link"><a href="reference/tracking.html"><img src="prev.gif" alt="tracking policies" border="0"><br>
-Tracking policies
+<div class="prev_link"><a href="performance.html"><img src="prev.gif" alt="performance" border="0"><br>
+Performance
</a></div>
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
</a></div>
-<div class="next_link"><a href="future_work.html"><img src="next.gif" alt="future work" border="0"><br>
-Future work
+<div class="next_link"><a href="tests.html"><img src="next.gif" alt="tests" border="0"><br>
+Tests
</a></div><br clear="all" style="clear: all;">
<br clear="all" style="clear: all;">
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
<li>Example 1: basic usage</li>
- <li>Example 2: flyweights and the composite pattern</li>
- <li>Example 3: formatted text processing</li>
- <li>Example 4: serialization</li>
- <li>Example 5: performance comparison</li>
- <li>Example 6: custom factory</li>
+ <li>Example 2: key-value flyweights</li>
+ <li>Example 3: flyweights and the composite pattern</li>
+ <li>Example 4: formatted text processing</li>
+ <li>Example 5: flyweight-based memoization</li>
+ <li>Example 6: serialization</li>
+ <li>Example 7: performance comparison</li>
+ <li>Example 8: custom factory</li>
</ul>
<h2><a name="example1">Example 1: basic usage</a></h2>
@@ -52,7 +52,25 @@
explained at the tutorial.
</p>
-<h2><a name="example2">Example 2: flyweights and the composite pattern</a></h2>
+<h2><a name="example2">Example 2: key-value flyweights</a></h2>
+
+<p>
+See source code.
+</p>
+
+<p>
+The program simulates the scenario described at the tutorial section on
+key-value flyweights: The class
+<code>texture</code> manages some texture rendering data stored in
+a file whose location is given at construction time. The program
+handles large quantities of objects of this class by encapsulating
+them into key-value flyweights keyed by filename. Observe how the
+execution of the program results in no extra constructions or copies
+of objects of type <code>texture</code> except those absolutely
+necessary.
+</p>
+
+<h2><a name="example3">Example 3: flyweights and the composite pattern</a></h2>
<p>
See source code.
@@ -91,7 +109,7 @@
<code>tan</code>, <code>(tan x)</code> and <code>(tan y)</code>.
</p>
-<h2><a name="example3">Example 3: formatted text processing</a></h2>
+<h2><a name="example4">Example 4: formatted text processing</a></h2>
<p>
See source code.
@@ -137,12 +155,53 @@
<p>
For the sake of brevity, the HTML parsing capabilities of this program
-are coarse: for instance, elements without end-tag (like <BR>), character
+are coarse: for instance, elements without end-tag (like <BR>), character
enconding and HTML entities (e.g. "&copy;" for ©) are not properly
handled. Improving the parsing code is left as an exercise to the reader.
</p>
-<h2><a name="example4">Example 4: serialization</a></h2>
+<h2><a name="example5">Example 5: flyweight-based memoization</a></h2>
+
+<p>
+See source code.
+</p>
+
+<p>
+Memoization
+is an optimization technique consisting in caching
+the results of a computation for later reuse; this can dramatically
+improve performance when calculating recursive numerical functions,
+for instance. Key-value flyweights
+can be used to implement memoization for a numerical function <i>f</i>
+by modeling a memoized invocation of the function as a value of
+type <code>flyweight<key_value<int,compute_f> ></code>, where
+<code>compute_f</code> is a type that does the computation of
+<i>f</i>(<i>n</i>) at its <code>compute_f::compute_f(int)</code> constructor.
+For instance, the <a href="http://mathworld.wolfram.com/FibonacciNumber.html">Fibonacci
+numbers</a> can be computed with memoization like this:
+</p>
+
+<blockquote><pre>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special><</span><span class=identifier>key_value</span><span class=special><</span><span class=keyword>int</span><span class=special>,</span><span class=identifier>compute_fibonacci</span><span class=special>>,</span><span class=identifier>no_tracking</span><span class=special>></span> <span class=identifier>fibonacci</span><span class=special>;</span>
+
+<span class=keyword>struct</span> <span class=identifier>compute_fibonacci</span>
+<span class=special>{</span>
+ <span class=identifier>compute_fibonacci</span><span class=special>(</span><span class=keyword>int</span> <span class=identifier>n</span><span class=special>):</span>
+ <span class=identifier>result</span><span class=special>(</span><span class=identifier>n</span><span class=special>==</span><span class=number>0</span><span class=special>?</span><span class=number>0</span><span class=special>:</span><span class=identifier>n</span><span class=special>==</span><span class=number>1</span><span class=special>?</span><span class=number>1</span><span class=special>:</span><span class=identifier>fibonacci</span><span class=special>(</span><span class=identifier>n</span><span class=special>-</span><span class=number>2</span><span class=special>).</span><span class=identifier>get</span><span class=special>()+</span><span class=identifier>fibonacci</span><span class=special>(</span><span class=identifier>n</span><span class=special>-</span><span class=number>1</span><span class=special>).</span><span class=identifier>get</span><span class=special>())</span>
+ <span class=special>{}</span>
+
+ <span class=keyword>operator</span> <span class=keyword>int</span><span class=special>()</span><span class=keyword>const</span><span class=special>{</span><span class=keyword>return</span> <span class=identifier>result</span><span class=special>;}</span>
+ <span class=keyword>int</span> <span class=identifier>result</span><span class=special>;</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+The no_tracking
+policy is used so that the memoized computations persist for future
+use throughout the program. The provided program develops this example in full.
+</p>
+
+<h2><a name="example6">Example 6: serialization</a></h2>
<p>
See source code.
@@ -168,7 +227,7 @@
<code>flyweight</code> objects.
</p>
-<h2><a name="example5">Example 5: performance comparison</a></h2>
+<h2><a name="example7">Example 7: performance comparison</a></h2>
<p>
See source code.
@@ -182,9 +241,11 @@
Memory consumption is computed by instrumenting the relevant
components (the string type itself, flyweight factories, etc.) with custom
allocators that keep track of the allocations and deallocations requested.
+The program has been used to produce the experimental results given
+at the performance section.
</p>
-<h2><a name="example6">Example 6: custom factory</a></h2>
+<h2><a name="example8">Example 8: custom factory</a></h2>
<p>
See source code.
@@ -198,20 +259,20 @@
<hr>
-<div class="prev_link"><a href="reference/tracking.html"><img src="prev.gif" alt="tracking policies" border="0"><br>
-Tracking policies
+<div class="prev_link"><a href="performance.html"><img src="prev.gif" alt="performance" border="0"><br>
+Performance
</a></div>
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
</a></div>
-<div class="next_link"><a href="future_work.html"><img src="next.gif" alt="future work" border="0"><br>
-Future work
+<div class="next_link"><a href="tests.html"><img src="next.gif" alt="tests" border="0"><br>
+Tests
</a></div><br clear="all" style="clear: all;">
<br clear="all" style="clear: all;">
<br>
-<p>Revised January 16th 2008</p>
+<p>Revised August 26th 2008</p>
<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
Modified: sandbox/flyweight/libs/flyweight/doc/future_work.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/future_work.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/future_work.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -8,28 +8,26 @@
<link rel="start" href="examples.html">
<link rel="prev" href="tests.html">
<link rel="up" href="index.html">
-<link rel="next" href="review_notes.html">
+<link rel="next" href="release_notes.html">
</head>
<body>
-<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Future work</h1>
-<div class="prev_link"><a href="examples.html"><img src="prev.gif" alt="examples" border="0"><br>
-Examples
+<div class="prev_link"><a href="tests.html"><img src="prev.gif" alt="examples" border="0"><br>
+Tests
</a></div>
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
</a></div>
-<div class="next_link"><a href="review_notes.html"><img src="next.gif" alt="review notes" border="0"><br>
-Review notes
+<div class="next_link"><a href="release_notes.html"><img src="next.gif" alt="release notes" border="0"><br>
+Release notes
</a></div><br clear="all" style="clear: all;">
<br clear="all" style="clear: all;">
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<p>
New functionalities can be included into future releases of Boost.Flyweight
to meet the demands of users and to leverage upcoming C++0x features
@@ -41,6 +39,7 @@
<ul>
<li>Introspection API</li>
<li>Perfect forwarding</li>
+ <li>Read/write locking policy</li>
<li>Integration with new Boost libraries</li>
</ul>
@@ -74,6 +73,23 @@
compilers begin to provide it.
</p>
+<h2><a name="rw_lock">Read/write locking policy</a></h2>
+
+<p>
+The nature of the flyweight pattern implies that most accesses
+to the internal flyweight factory do not cause new insertions and can
+thus be considered read-only. This hints at the convenience of using
+a locking policy based on read/write locks such as those provided by
+Boost.Thread.
+Implementing a locking policy will also require extending the
+Factory
concept
+to allow for pure lookup operations. Tim Blechmann has provided a
+preliminary implementation
+of this idea. Before committing to this library extension it is
+necessary to do a profiling study to determine whether read/write
+locking actually improves performance.
+</p>
+
<h2><a name="new_boost_libs">Integration with new Boost libraries</a></h2>
<p>
@@ -86,20 +102,20 @@
<hr>
-<div class="prev_link"><a href="examples.html"><img src="prev.gif" alt="examples" border="0"><br>
-Examples
+<div class="prev_link"><a href="tests.html"><img src="prev.gif" alt="examples" border="0"><br>
+Tests
</a></div>
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
</a></div>
-<div class="next_link"><a href="review_notes.html"><img src="next.gif" alt="review notes" border="0"><br>
-Review notes
+<div class="next_link"><a href="release_notes.html"><img src="next.gif" alt="release notes" border="0"><br>
+Release notes
</a></div><br clear="all" style="clear: all;">
<br clear="all" style="clear: all;">
<br>
-<p>Revised January 9th 2008</p>
+<p>Revised September 1st 2008</p>
<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
Modified: sandbox/flyweight/libs/flyweight/doc/index.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/index.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/index.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -10,7 +10,7 @@
</head>
<body>
-<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost Flyweight Library</h1>
<div class="prev_link"></div>
@@ -21,8 +21,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<p>
Flyweights are small-sized handle classes granting constant access to shared
common data, thus allowing for the management of large amounts of entities
@@ -53,10 +51,11 @@
<ul>
<li>Tutorial</li>
<li>Reference</li>
+ <li>Performance</li>
<li>Examples</li>
<li>Tests</li>
<li>Future work</li>
- <li>Review notes</li>
+ <li>Review notes</li>
<li>Acknowledgements</li>
</ul>
@@ -70,7 +69,7 @@
<br>
-<p>Revised January 8th 2008</p>
+<p>Revised August 27th 2008</p>
<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
Modified: sandbox/flyweight/libs/flyweight/doc/reference/factories.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/factories.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/factories.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight
Factories reference</h1>
@@ -28,8 +28,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -76,16 +74,16 @@
<h2><a name="factory">Factories and factory specifiers</a></h2>
<p>
-Given a type <code>Value</code> and an
+Given a type <code>Key</code> and an
<a href="http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable</code></a>
-type <code>Entry</code> implicitly convertible to <code>const Value&</code>, a
+type <code>Entry</code> implicitly convertible to <code>const Key&</code>, a
<i>factory of <code>Entry</code> elements</i> (implicitly associated to
-<code>Value</code>) is a
+<code>Key</code>) is a
<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
Constructible</code></a> entity able to store and retrieve immutable elements of
type <code>Entry</code>. A factory is governed by an associated equivalence
-relation defined on <code>Value</code> so that no two
-<code>Entry</code> objects convertible to equivalent <code>Value</code>s
+relation defined on <code>Key</code> so that no two
+<code>Entry</code> objects convertible to equivalent <code>Key</code>s
can be stored simultaneously in the factory. Different factory types can
use different equivalence relations.
</p>
@@ -126,12 +124,16 @@
<tr>
<td><code>f.erase(h);</code></td>
<td><code>void</code></td>
- <td>Erases the element associated to <code>h</code>.</td>
+ <td>Erases the element associated to <code>h</code>.<br>
+ This operation does not throw.
+ </td>
</tr>
<tr class="odd_tr">
<td><code>f.entry(h);</code></td>
- <td><code>const Entry&</code></td>
- <td>Returns a reference to the element associated to <code>h</code>.</td>
+ <td><code>const Entry&</code></td>
+ <td>Returns a reference to the element associated to <code>h</code>.<br>
+ This operation does not throw.
+ </td>
</tr>
</table>
</p>
@@ -159,8 +161,8 @@
<li><code>S</code>, or <code>S'</code> if (b) applies, is an
<a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
Expression</code></a> such that invoking it with types (<code>Entry</code>,
- <code>Value</code>) resolves to a factory type of <code>Entry</code> elements
- (implicitly associated to <code>Value</code>).
+ <code>Key</code>) resolves to a factory type of <code>Entry</code> elements
+ (implicitly associated to <code>Key</code>).
</li>
</ol>
</p>
@@ -186,7 +188,7 @@
<span class=special>}</span> <span class=comment>// namespace boost</span>
</pre></blockquote>
-<h3><a name="is_factory">Class template <code>is_factory</code></h3>
+<h3><a name="is_factory">Class template <code>is_factory</code></a></h3>
<p>
Unless specialized by the user, <code>is_factory<T>::type</code> is
@@ -196,7 +198,7 @@
otherwise.
</p>
-<h3><a name="factory_construct">Class template <code>factory</code></h3>
+<h3><a name="factory_construct">Class template <code>factory</code></a></h3>
<p>
<code>factory<T></code> is a syntactic construct meant to indicate
@@ -213,7 +215,7 @@
<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
<span class=keyword>template</span><span class=special><</span>
- <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Key</span><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Hash</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Pred</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>=</span><b>implementation defined</b>
@@ -250,7 +252,7 @@
<blockquote><pre>
<span class=keyword>template</span><span class=special><</span>
- <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Key</span><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Hash</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Pred</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
<span class=special>></span>
<span class=keyword>class</span> <span class=identifier>hashed_factory_class</span>
@@ -269,7 +271,7 @@
<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
Constructible</code></a>
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html"><code>Unary Function</code></a>
-taking a single argument of type <code>Value</code> and returning a
+taking a single argument of type <code>Key</code> and returning a
value of type <code>std::size_t</code> in the range
<code>[0, std::numeric_limits<std::size_t>::max())</code>.
<code>Pred</code> is a
@@ -277,14 +279,14 @@
Constructible</code></a>
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">
<code>Binary Predicate</code></a> inducing an equivalence relation
-on elements of <code>Value</code>. It is required that
+on elements of <code>Key</code>. It is required that
a <code>Hash</code> object return the same value for objects
equivalent under <code>Pred</code>.
-The equivalence relation on <code>Value</code> associated to the factory is
+The equivalence relation on <code>Key</code> associated to the factory is
that induced by <code>Pred</code>.
The default arguments for <code>Hash</code> and <code>Pred</code> are
-boost::hash<Value>
-and <code>std::equal_to<Value></code>, respectively.
+boost::hash<Key>
+and <code>std::equal_to<Key></code>, respectively.
<code>Allocator</code> must be an allocator of <code>Entry</code> objects
satisfying the associated C++ requirements at <b>[lib.allocator.requirements]</b>.
The default argument is <code>std::allocator<Entry></code>. The internal
@@ -313,7 +315,7 @@
<blockquote><pre>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>apply</span><span class=special><</span>
<span class=identifier>hashed_factory</span><span class=special><</span><span class=identifier>Hash</span><span class=special>,</span><span class=identifier>Pred</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span>
- <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span>
<span class=special>>::</span><span class=identifier>type</span>
</pre></blockquote>
@@ -324,7 +326,7 @@
<blockquote><pre>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>apply</span><span class=special><</span>
<span class=identifier>hashed_factory_class</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>,</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_2</span><span class=special>,</span><span class=identifier>Hash</span><span class=special>,</span><span class=identifier>Pred</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span>
- <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span>
<span class=special>>::</span><span class=identifier>type</span>
</pre></blockquote>
@@ -345,7 +347,7 @@
<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
<span class=keyword>template</span><span class=special><</span>
- <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Key</span><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Compare</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>=</span><b>implementation defined</b>
<span class=special>></span>
@@ -380,7 +382,7 @@
<blockquote><pre>
<span class=keyword>template</span><span class=special><</span>
- <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Key</span><span class=special>,</span>
<span class=keyword>typename</span> <span class=identifier>Compare</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
<span class=special>></span>
<span class=keyword>class</span> <span class=identifier>set_factory_class</span>
@@ -399,10 +401,10 @@
<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
Constructible</code></a>
<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
-<code>Strict Weak Ordering</code></a> on <code>Value</code>. Two <code>Value</code>s
+<code>Strict Weak Ordering</code></a> on <code>Key</code>. Two <code>Key</code>s
<code>x</code> and <code>y</code> are considered equivalent if
-<code>!c(x,y)&&!c(y,x)</code> for <code>c</code> of type <code>Compare</code>.
-The default argument of <code>Compare</code> is <code>std::less<Value></code>
+<code>!c(x,y)&&!c(y,x)</code> for <code>c</code> of type <code>Compare</code>.
+The default argument of <code>Compare</code> is <code>std::less<Key></code>
<code>Allocator</code> must be an allocator of <code>Entry</code> objects
satisfying the associated C++ requirements at <b>[lib.allocator.requirements]</b>.
The default argument is <code>std::allocator<Entry></code>. The internal
@@ -431,7 +433,7 @@
<blockquote><pre>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>apply</span><span class=special><</span>
<span class=identifier>set_factory</span><span class=special><</span><span class=identifier>Compare</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span>
- <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span>
<span class=special>>::</span><span class=identifier>type</span>
</pre></blockquote>
@@ -442,7 +444,7 @@
<blockquote><pre>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>apply</span><span class=special><</span>
<span class=identifier>set_factory_class</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>,</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_2</span><span class=special>,</span><span class=identifier>Compare</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>>,</span>
- <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span>
<span class=special>>::</span><span class=identifier>type</span>
</pre></blockquote>
@@ -549,9 +551,9 @@
<code>ContainerSpecifier</code> must be an
<a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
Expression</code></a> resolving, when invoked with (<code>Entry</code>,
-<code>Value</code>), to a type <code>Container</code> such that
+<code>Key</code>), to a type <code>Container</code> such that
<code>assoc_container_factory_class<Container></code> is a factory
-of <code>Entry</code> elements implicitly associated to <code>Value</code>.
+of <code>Entry</code> elements implicitly associated to <code>Key</code>.
</p>
<hr>
@@ -568,9 +570,9 @@
<br>
-<p>Revised November 26th 2007</p>
+<p>Revised August 13th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -8,11 +8,11 @@
<link rel="start" href="../index.html">
<link rel="prev" href="index.html">
<link rel="up" href="index.html">
-<link rel="next" href="tags.html">
+<link rel="next" href="key_value.html">
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight
<code>flyweight</code> reference</h1>
@@ -22,14 +22,12 @@
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
Boost.Flyweight reference
</a></div>
-<div class="next_link"><a href="tags.html"><img src="../next.gif" alt="tags" border="0"><br>
-Tags
+<div class="next_link"><a href="key_value.html"><img src="../next.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div><br clear="all" style="clear: all;">
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -43,7 +41,7 @@
<li>Instantiation types</li>
<li>Static data initialization</li>
<li>Constructors, copy and assignment</li>
- <li>Convertibility to the underlying type</li>
+ <li>Convertibility to the underlying types</li>
<li>Modifiers</li>
<li>Comparison operators</li>
<li>Specialized algorithms</li>
@@ -61,7 +59,7 @@
</ul>
<h2>
-<a name="#flyweight_fwd_synopsis">Header
+<a name="flyweight_fwd_synopsis">Header
<a href="../../../../boost/flyweight/flyweight_fwd.hpp"><code>"boost/flyweight/flyweight_fwd.hpp"</code></a>
synopsis</a>
</h2>
@@ -150,26 +148,34 @@
</a></h3>
<p>
-Objects of type <code>flyweight<T,...></code> provide access to immutable
-values of type <code>T</code>, with the following advantages over using
-plain <code>T</code> objects:
+Objects of type <code>flyweight<...></code> provide access to immutable
+values of type <code>flyweight<...>::value_type</code>, with the following advantages over using
+plain <code>value_type</code> objects:
<ul>
<li>Flyweight objects with equivalent value share the same representation
- (the associated <code>T</code> object).
+ (the associated <code>value_type</code> object).
</li>
<li>The size of flyweights is typically that of a pointer, which is in general
- smaller than <code>sizeof(T)</code>.
+ smaller than <code>sizeof(value_type)</code>.
</li>
</ul>
So, if the level of redundancy (ratio of total objects to different values)
-is high enough, substituting <code>flyweight<T,...></code> for
-<code>T</code> results in a reduction in memory usage.
+is high enough, substituting a suitable instantiation of <code>flyweight</code>
+for <code>value_type</code> results in a reduction in memory usage.
</p>
<p>
<code>flyweight</code> is parameterized according to some aspects:
<ul>
+ <li>Types <code>key_value</code> and <code>value_type</code>
+ (possibly equal), where <code>key_type</code> serves as a
+ key type to lookup and construct internal shared instances of
+ objects of <code>value_type</code>.
+ </li>
+ <li>An optional tag type meant to syntactically
+ differentiate between otherwise identical instantiations.
+ </li>
<li>The factory class used to store
and retrieve the shared value objects.
</li>
@@ -196,9 +202,10 @@
</li>
<li>The flyweight factory stores elements of an undisclosed type
<code>Entry</code> that is implicitly convertible to
- <code>const T&</code>. Every flyweight object is associated
- to a <code>const T</code> reference resulting from the conversion
- from some <code>Entry</code> stored in the factory.
+ <code>const key_type&</code> and also stores a subobject of
+ <code>value_type</code>. Every flyweight object is associated
+ to a <code>value_type</code> subobject of some <code>Entry</code>
+ stored in the factory.
</li>
<li>The associated mutex object is used to protect all invocations
to the insertion and deletion functions of the internal flyweight
@@ -211,8 +218,11 @@
manner described for this concept.
</li>
</ul>
-In what follows, we implicitly assume that <code>T</code> equivalence
+In what follows, we implicitly assume that <code>key_type</code> equivalence
refers to the equivalence relationship induced by the factory class used.
+Also, two values of <code>value_type</code> are considered equivalent
+if they are constructed from equivalent keys, or are copies of
+objects constructed from equivalent keys.
</p>
<blockquote><pre>
@@ -223,7 +233,8 @@
<span class=keyword>class</span> <span class=identifier>flyweight</span>
<span class=special>{</span>
<span class=keyword>public</span><span class=special>:</span>
- <span class=keyword>typedef</span> <span class=identifier>T</span> <span class=identifier>value_type</span><span class=special>;</span>
+ <span class=keyword>typedef</span> <span class=identifier><b>dependent on T</b></span> <span class=identifier>key_type</span><span class=special>;</span>
+ <span class=keyword>typedef</span> <span class=identifier><b>dependent on T</b></span> <span class=identifier>value_type</span><span class=special>;</span>
<span class=comment>// static data initialization:</span>
@@ -249,13 +260,14 @@
<span class=identifier>flyweight</span><span class=special>([</span><span class=keyword>const</span><span class=special>]</span> <span class=identifier>T0</span><span class=special>&</span> <span class=identifier>t0</span><span class=special>,...,[</span><span class=keyword>const</span><span class=special>]</span> <span class=identifier>Tn</span><span class=special>-</span><span class=number>1</span><span class=special>&</span> <span class=identifier>tn</span><span class=special>-</span><span class=number>1</span><span class=special>);</span>
<span class=identifier>flyweight</span><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
- <span class=identifier>flyweight</span><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <span class=identifier>T</span><span class=special>&</span> <span class=identifier>t</span><span class=special>);</span>
+ <span class=identifier>flyweight</span><span class=special>&</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
<span class=comment>// convertibility to underlying type:</span>
-
- <span class=keyword>const</span> <span class=identifier>T</span><span class=special>&</span> <span class=identifier>get</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
- <span class=keyword>operator</span> <span class=keyword>const</span> <span class=identifier>T</span><span class=special>&()</span><span class=keyword>const</span><span class=special>;</span>
-
+
+ <span class=keyword>const</span> <span class=identifier>key_type</span><span class=special>&</span> <span class=identifier>get_key</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
+ <span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&</span> <span class=identifier>get</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
+ <span class=keyword>operator</span> <span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&()</span><span class=keyword>const</span><span class=special>;</span>
+
<span class=comment>// modifiers:</span>
<span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><span class=identifier>flyweight</span><span class=special>&</span> <span class=identifier>x</span><span class=special>);</span>
@@ -265,12 +277,33 @@
<h4><a name="instantiation_types">Instantiation types</a></h4>
<p>
-<code>T</code> is the type of the values flyweight objects give access to.
-<code>T</code> must be
+<code>T</code> can be either:
+<ul>
+ <li>An arbitrary type,</li>
+ <li>a type of the form
+ key_value<Key,Value[,KeyFromValue]>
.</li>
+</ul>
+In the first case, the nested types <code>key_type</code> and <code>value_type</code>
+are both equal to <code>T</code>. In the second case, <code>key_type</code>=<code>Key</code>,
+<code>value_type</code>=<code>Value</code>; we say then that the instantiation
+of <code>flyweight</code> is a <i>key-value</i> flyweight.
+<code>value_type</code> is the type of the values flyweight objects give access to,
+while value lookup is based on associated <code>key_type</code> values.
+<code>key_value</code> must be
<a href="http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable</code></a>
-and conform to any extra requirements imposed by the type of factory used. The types
-<code>Arg1</code>, ... , <code>Arg5</code>, if provided, must be any of the
-following, in no particular order:
+and <code>value_type</code> must be constructible from <code>key_type</code>;
+additionally, <code>key_value</code> must
+conform to any extra requirements imposed by the type of factory used.
+For key-value flyweights, it is guaranteed that the creation or assignment of a flyweight
+object results in at most one construction (or copy construction in some
+particular cases) of an object
+of <code>value_type</code>, and this construction only occurs in the case that no
+equivalent value existed previously in the flyweight factory.
+</p>
+
+<p>
+The types <code>Arg1</code>, ... , <code>Arg5</code>, if provided, must be any
+of the following, in no particular order:
<ul>
<li>A tag,</li>
<li>a factory specifier,</li>
@@ -298,8 +331,8 @@
<p>
The static data internal to a given <code>flyweight</code> instantiation
(factory instance, etc.) is constructed during the dynamic initialization
-phase of the program or just before the first program-wide use of the
-instantiated class, whichever comes first. The following utilities can be
+phase of the program and always before the first program-wide use of the
+instantiated class. The following utilities can be
used when more control about the moment of construction is required.
</p>
@@ -323,11 +356,11 @@
<code>flyweight();</code>
<blockquote>
-<b>Requires:</b> <code>T</code> is
+<b>Requires:</b> <code>key_type</code> is
<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
Constructible</code></a>.<br>
<b>Effects:</b> Constructs a <code>flyweight</code> object associated
-to the default value of <code>T</code>.
+with value <code>value_type(key_type())</code>.
</blockquote>
<code>flyweight(const flyweight& x);<br>
@@ -339,7 +372,7 @@
<b>Exception safety:</b> <code>nothrow</code>.
</blockquote>
-<a name="#fwd_ctors">
+<a name="fwd_ctors">
<code>template<typename T0><br>
explicit flyweight([const] T0& t0);<br>
template<typename T0,typename T1><br>
@@ -350,7 +383,7 @@
<blockquote>
<b>Effects:</b> Constructs a <code>flyweight</code> object with value
-<code>T(t0,...,ti)</code>, up to an implementation defined number
+<code>value_type(key_type(t0,...,ti))</code>, up to an implementation defined number
of arguments.<br>
<b>Note:</b> In this implementation, the maximum number of arguments
can be globally configured by the user.
@@ -365,18 +398,38 @@
<b>Exception safety:</b> <code>nothrow</code>.
</blockquote>
-<code>flyweight& operator=(const T& t);</code>
+<code>flyweight& operator=(const value_type& x);</code>
<blockquote>
-<b>Effects:</b> Associates the <code>flyweight</code> object with value
-<code>t</code>.<br>
+<b>Requires:</b> If <code>flyweight</code> is key-value,
+<code>value_type</code> is
+Assignable
+and the
+Key Extractor
+<code>KeyFromValue</code> must have been supplied as part of the
+<code>key_value<></code> construct.<br>
+<b>Effects:</b> Associates the <code>flyweight</code> object with a
+copy of <code>x</code> or with a <code>value_type</code> constructed
+from a key equivalent to that associated to <code>x</code>. For non-key-value
+flyweights, <code>x</code> is its own key; for key-value flyweights,
+the key is extracted through use of an object of type <code>KeyFromValue</code>.<br>
<b>Returns:</b> <code>*this</code>.<br>
</blockquote>
-<h4><a name="convertibility">Convertibility to the underlying type</a></h4>
+<h4><a name="convertibility">Convertibility to the underlying types</a></h4>
-<code>const T& get()const;<br>
-operator const T&()const;</code>
+<code>const key_type& get_key()const;</code>
+
+<blockquote>
+<b>Return:</b> A copy of the key used to construct the
+<code>value_type</code> associated to the <code>flyweight</code>
+object.<br>
+<b>Exception safety:</b> If <code>flyweight</code> is not key-value or
+if <code>KeyFromValue</code> was not provided, <code>nothrow</code>.
+</blockquote>
+
+<code>const value_type& get()const;<br>
+ operator const value_type&()const;</code>
<blockquote>
<b>Return:</b> The value associated to the <code>flyweight</code>
@@ -389,8 +442,9 @@
<code>void swap(flyweight& x);</code>
<blockquote>
-<b>Effects:</b> Swaps the associations to <code>T</code> values each
-flyweight object has. No swapping of <code>T</code> objects is done.<br>
+<b>Effects:</b> Swaps the associations to <code>value_type</code>s each
+flyweight object has. No swapping of <code>key_type</code> or
+<code>value_type</code> objects is done.<br>
<b>Exception safety:</b> <code>nothrow</code>.
</blockquote>
@@ -531,7 +585,14 @@
flyweight<T,Arg1,...,Arg5>& x);</code>
<blockquote>
-<b>Effects:</b> Reads an object of type <code>T</code> from <code>in</code>
+<b>Requires:</b> If <code>flyweight</code> is key-value,
+<code>value_type</code> is
+Assignable
+and the
+Key Extractor
+<code>KeyFromValue</code> must have been supplied as part of the
+<code>key_value<></code> construct.<br>
+<b>Effects:</b> Reads an object of type <code>value_type</code> from <code>in</code>
and assigns it to <code>x</code>.<br>
<b>Returns:</b> <code>in</code>.
</blockquote>
@@ -539,7 +600,7 @@
<h4><a name="config_macros">Configuration macros</a></h4>
<a name="limit_num_ctor_args">
-<code>BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS</code></a>
+<code>BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS</code></a>
<blockquote>
<b>Effects:</b> Globally define this macro to set the maximum number of
@@ -567,8 +628,8 @@
<a href="../../../serialization/index.html">Boost.Serialization</a>. Regular as well
as XML archives are supported.
Serialization is done in an efficient manner so that saving equivalent <code>flyweight</code>s
-result in their common value being stored only once, regardless of whether the
-underlying type is
+result in their common <code>key_type</code> value being stored only once, regardless
+of whether <code>key_type</code> is
<a href="../../../serialization/doc/traits.html#tracking">tracked</a> by
Boost.Serialization or not.
</p>
@@ -577,10 +638,10 @@
output archive (XML archive) <code>ar</code>.
<blockquote>
-<b>Requires:</b> The underlying type <code>T</code> is serializable (XML-serializable).<br>
-<b>Effects:</b> The value <code>t=x.get()</code> is saved into <code>ar</code> as
+<b>Requires:</b> <code>key_type</code> is serializable (XML-serializable).<br>
+<b>Effects:</b> The value <code>k=x.get_key()</code> is saved into <code>ar</code> as
part of this operation or of a previous saving operation of a <code>flyweight</code>
-object with the same value.<br>
+object with the same key.<br>
<b>Exception safety:</b> Strong with respect to <code>x</code>. If an exception
is thrown, <code>ar</code> may be left in an inconsistent state.
</blockquote>
@@ -589,9 +650,10 @@
input archive (XML archive) <code>ar</code>.
<blockquote>
-<b>Requires:</b> The underlying type <code>T</code> is serializable (XML-serializable).<br>
-<b>Effects:</b> <code>x'</code> is associated to a value equivalent to
-<code>t'</code>, a restored copy of the value <code>t</code> defined above.<br>
+<b>Requires:</b> <code>key_type</code> is serializable (XML-serializable).<br>
+<b>Effects:</b> <code>x'</code> is associated to a value constructed from a key
+equivalent to <code>k'</code>, a restored copy of the value <code>k</code>
+defined above.<br>
<b>Exception safety:</b> Strong with respect to <code>x'</code>. If an exception
is thrown, <code>ar</code> may be left in an inconsistent state.
</blockquote>
@@ -604,15 +666,15 @@
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
Boost.Flyweight reference
</a></div>
-<div class="next_link"><a href="tags.html"><img src="../next.gif" alt="tags" border="0"><br>
-Tags
+<div class="next_link"><a href="key_value.html"><img src="../next.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div><br clear="all" style="clear: all;">
<br>
-<p>Revised December 17th 2007</p>
+<p>Revised August 13th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/reference/holders.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/holders.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/holders.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight
Holders reference</h1>
@@ -28,8 +28,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -69,7 +67,9 @@
Given a type <code>C</code>, a type <code>Holder</code> is said to be a <i>holder
of <code>C</code></i> if the expression <code>Holder::get()</code> returns
a reference to a default initialized <code>C</code> object unique to
-<code>Holder</code>. flyweight
+<code>Holder</code>. No invocation of <code>Holder::get()</code>, except possibly
+the first one in the program, does throw.
+flyweight
privately uses a holder to instantiate a factory
and some additional data (like a mutex for
internal synchronization) unique to each instantiation type of the class template.
@@ -114,7 +114,7 @@
<span class=special>}</span> <span class=comment>// namespace boost</span>
</pre></blockquote>
-<h3><a name="is_holder">Class template <code>is_holder</code></h3>
+<h3><a name="is_holder">Class template <code>is_holder</code></a></h3>
<p>
Unless specialized by the user, <code>is_holder<T>::type</code> is
@@ -124,7 +124,7 @@
otherwise.
</p>
-<h3><a name="holder_construct">Class template <code>holder</code></h3>
+<h3><a name="holder_construct">Class template <code>holder</code></a></h3>
<p>
<code>holder<T></code> is a syntactic construct meant to indicate
@@ -230,9 +230,9 @@
<br>
-<p>Revised September 27th 2007</p>
+<p>Revised August 11th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/reference/index.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/index.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/index.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Reference</h1>
<div class="prev_link"><a href="../tutorial/lambda_expressions.html"><img src="../prev.gif" alt="annex: MPL lambda expressions" border="0"><br>
@@ -27,8 +27,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -36,6 +34,7 @@
<li><a href="#flyweight_synopsis">Header
<code>"boost/flyweight.hpp"</code> synopsis</a></li>
<li>Class template flyweight
</li>
+ <li>Key-value flyweights</li>
<li>Tags</li>
<li>Factories</li>
<li>Holders</li>
@@ -56,6 +55,12 @@
<li>"boost/flyweight/flyweight_serialize.hpp"
</li>
</ul>
</li>
+ <li>Key-value flyweights
+ <ul>
+ <li>"boost/flyweight/key_value_fwd.hpp"
</li>
+ <li>"boost/flyweight/key_value.hpp"
</li>
+ </ul>
+ </li>
<li>Tags
<ul>
<li>"boost/flyweight/tag.hpp"
</li>
@@ -110,7 +115,7 @@
</p>
<h2>
-<a name="#flyweight_synopsis">Header
+<a name="flyweight_synopsis">Header
<a href="../../../../boost/flyweight.hpp"><code>"boost/flyweight.hpp"</code></a>
synopsis</a>
</h2>
@@ -143,9 +148,9 @@
<br>
-<p>Revised August 16th 2007</p>
+<p>Revised August 11th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/reference/locking.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/locking.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/locking.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight
Locking policies reference</h1>
@@ -28,18 +28,16 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
<li>Preliminary concepts</li>
<li>Locking policies</li>
- <li><a href="#tracking_tag_synopsis">Header
- <code>"boost/flyweight/tracking_tag.hpp"</code> synopsis</a>
+ <li><a href="#locking_tag_synopsis">Header
+ <code>"boost/flyweight/locking_tag.hpp"</code> synopsis</a>
<ul>
- <li>Class template is_tracking
</li>
- <li>Class template tracking
</li>
+ <li>Class template is_locking
</li>
+ <li>Class template locking
</li>
</ul>
</li>
<li><a href="#simple_locking_fwd_synopsis">Header
@@ -99,7 +97,7 @@
</td>
</tr>
<tr class="odd_tr">
- <td><code>(&m)->~Mutex();</td>
+ <td><code>(&m)->~Mutex();</code></td>
<td><code>void</code></td>
<td>Pre: <code>m</code> is unlocked.</td>
</tr>
@@ -109,7 +107,7 @@
<td>Associates <code>m</code> to <code>lk</code> and locks <code>m</code>.</td>
</tr>
<tr class="odd_tr">
- <td><code>(&lk)->~Lock();</td>
+ <td><code>(&lk)->~Lock();</code></td>
<td><code>void</code></td>
<td>Unlocks the mutex associated to <code>lk</code>.</td>
</tr>
@@ -178,7 +176,7 @@
<span class=special>}</span> <span class=comment>// namespace boost</span>
</pre></blockquote>
-<h3><a name="is_locking">Class template <code>is_locking</code></h3>
+<h3><a name="is_locking">Class template <code>is_locking</code></a></h3>
<p>
Unless specialized by the user, <code>is_locking<T>::type</code> is
@@ -188,7 +186,7 @@
otherwise.
</p>
-<h3><a name="locking_construct">Class template <code>locking</code></h3>
+<h3><a name="locking_construct">Class template <code>locking</code></a></h3>
<p>
<code>locking<T></code> is a syntactic construct meant to indicate
@@ -276,7 +274,7 @@
<br>
-<p>Revised January 16th 2008</p>
+<p>Revised August 13th 2008</p>
<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
Modified: sandbox/flyweight/libs/flyweight/doc/reference/tags.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/tags.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/tags.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -6,18 +6,18 @@
<title>Boost.Flyweight Documentation - Tags reference</title>
<link rel="stylesheet" href="../style.css" type="text/css">
<link rel="start" href="../index.html">
-<link rel="prev" href="flyweight.html">
+<link rel="prev" href="key_value.html">
<link rel="up" href="index.html">
<link rel="next" href="factories.html">
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight
Tags reference</h1>
-<div class="prev_link"><a href="flyweight.html"><img src="../prev.gif" alt="flyweight reference" border="0"><br>
-<code>flyweight</code> reference
+<div class="prev_link"><a href="key_value.html"><img src="../prev.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div>
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
Boost.Flyweight reference
@@ -28,8 +28,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -37,7 +35,7 @@
<li><a href="#tag_synopsis">Header
<code>"boost/flyweight/tag.hpp"</code> synopsis</a>
<ul>
- <li><a href="#tag_construct">Class template <code>tag</code></li>
+ <li>Class template tag
</li>
</ul>
</li>
</ul>
@@ -74,7 +72,7 @@
<span class=special>}</span> <span class=comment>// namespace boost</span>
</pre></blockquote>
-<h3><a name="tag_construct">Class template <code>tag</code></h3>
+<h3><a name="tag_construct">Class template <code>tag</code></a></h3>
<p>
For any type <code>T</code>, <code>tag<T></code> is a suitable
@@ -84,8 +82,8 @@
<hr>
-<div class="prev_link"><a href="flyweight.html"><img src="../prev.gif" alt="flyweight reference" border="0"><br>
-<code>flyweight</code> reference
+<div class="prev_link"><a href="key_value.html"><img src="../prev.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div>
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
Boost.Flyweight reference
@@ -96,9 +94,9 @@
<br>
-<p>Revised August 6th 2007</p>
+<p>Revised August 11th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/reference/tracking.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/reference/tracking.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/reference/tracking.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -8,11 +8,11 @@
<link rel="start" href="../index.html">
<link rel="prev" href="locking.html">
<link rel="up" href="index.html">
-<link rel="next" href="../examples.html">
+<link rel="next" href="../performance.html">
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight
Tracking policies reference</h1>
@@ -22,14 +22,12 @@
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
Boost.Flyweight reference
</a></div>
-<div class="next_link"><a href="../examples.html"><img src="../next.gif" alt="examples" border="0"><br>
-Examples
+<div class="next_link"><a href="../performance.html"><img src="../next.gif" alt="performance" border="0"><br>
+Performance
</a></div><br clear="all" style="clear: all;">
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -88,7 +86,7 @@
</tr>
<tr>
<td><code>TrackingHelper::entry(h);</code></td>
- <td><code>const Entry&</code></td>
+ <td><code>const Entry&</code></td>
<td>Returns <code>f.entry(h)</code>.</td>
</tr>
<tr class="odd_tr">
@@ -131,11 +129,13 @@
<li>The expression <code>Tracking::entry_type</code> (or
<code>Tracking'::entry_type</code> if (b) applies) is an
<a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
- Expression</code></a> that resolves, when invoked with an
- Assignable
- type <code>Value</code>, to an
+ Expression</code></a> that resolves, when invoked with different types
+ (<code>Value</code>,<code>Key</code>) such that <code>Value</code> is
+ Assignable
+ and implicitly convertible to <code>const Key&</code>, to an
<a href="http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable</code></a>
- type <code>Entry</code> implicitly convertible to <code>const Value&</code>.
+ type <code>Entry</code> implicitly convertible to both <code>const Value&</code>
+ and <code>const Key&</code>.
</li>
<li>The expression <code>Tracking::handle_type</code> (or
<code>Tracking'::handle_type</code> if (b) applies) is an
@@ -181,7 +181,7 @@
<span class=special>}</span> <span class=comment>// namespace boost</span>
</pre></blockquote>
-<h3><a name="is_tracking">Class template <code>is_tracking</code></h3>
+<h3><a name="is_tracking">Class template <code>is_tracking</code></a></h3>
<p>
Unless specialized by the user, <code>is_tracking<T>::type</code> is
@@ -191,7 +191,7 @@
otherwise.
</p>
-<h3><a name="tracking_construct">Class template <code>tracking</code></h3>
+<h3><a name="tracking_construct">Class template <code>tracking</code></a></h3>
<p>
<code>tracking<T></code> is a syntactic construct meant to indicate
@@ -272,13 +272,13 @@
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
Boost.Flyweight reference
</a></div>
-<div class="next_link"><a href="../examples.html"><img src="../next.gif" alt="examples" border="0"><br>
-Examples
+<div class="next_link"><a href="../performance.html"><img src="../next.gif" alt="performance" border="0"><br>
+Performance
</a></div><br clear="all" style="clear: all;">
<br>
-<p>Revised January 8th 2008</p>
+<p>Revised August 18th 2008</p>
<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
Modified: sandbox/flyweight/libs/flyweight/doc/tests.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tests.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tests.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -8,11 +8,11 @@
<link rel="start" href="index.html">
<link rel="prev" href="examples.html">
<link rel="up" href="index.html">
-<link rel="next" href="acknowledgements.html">
+<link rel="next" href="future_work.html">
</head>
<body>
-<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tests</h1>
<div class="prev_link"><a href="examples.html"><img src="prev.gif" alt="examples" border="0"><br>
@@ -21,8 +21,8 @@
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
</a></div>
-<div class="next_link"><a href="acknowledgements.html"><img src="next.gif" alt="acknowledgements" border="0"><br>
-Acknowledgements
+<div class="next_link"><a href="future_work.html"><img src="next.gif" alt="future work" border="0"><br>
+Future work
</a></div><br clear="all" style="clear: all;">
<hr>
@@ -63,7 +63,7 @@
<tr>
<td>test_intermod_holder.cpp
<br>
<a href="../test/intermod_holder_dll.cpp"><code>intermod_holder_dll.cpp</code></a></td>
- <td>Exercises intermodule_holder
.</td>
+ <td>Exercises intermodule_holder
.</td>
</tr>
<tr class="odd_tr">
<td>test_multictor.cpp
</td>
@@ -72,11 +72,11 @@
</tr>
<tr>
<td>test_no_locking.cpp
</td>
- <td>no_locking
policy.</td>
+ <td>no_locking
policy.</td>
</tr>
<tr class="odd_tr">
<td>test_no_tracking.cpp
</td>
- <td>no_tracking
policy.</td>
+ <td>no_tracking
policy.</td>
</tr>
<tr>
<td>test_serialization.cpp
</td>
@@ -99,16 +99,16 @@
<div class="up_link"><a href="index.html"><img src="up.gif" alt="index" border="0"><br>
Index
</a></div>
-<div class="next_link"><a href="acknowledgements.html"><img src="next.gif" alt="acknowledgements" border="0"><br>
-Acknowledgements
+<div class="next_link"><a href="future_work.html"><img src="next.gif" alt="future work" border="0"><br>
+Future work
</a></div><br clear="all" style="clear: all;">
<br>
-<p>Revised November 27th 2007</p>
+<p>Revised August 11th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -8,11 +8,11 @@
<link rel="start" href="../index.html">
<link rel="prev" href="index.html">
<link rel="up" href="index.html">
-<link rel="next" href="configuration.html">
+<link rel="next" href="key_value.html">
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tutorial: Basics</h1>
<div class="prev_link"><a href="index.html"><img src="../prev.gif" alt="Boost.Flyweight tutorial" border="0"><br>
@@ -21,14 +21,12 @@
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight tutorial" border="0"><br>
Boost.Flyweight tutorial
</a></div>
-<div class="next_link"><a href="configuration.html"><img src="../next.gif" alt="configuring Boost.Flyweight" border="0"><br>
-Configuring Boost.Flyweight
+<div class="next_link"><a href="key_value.html"><img src="../next.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div><br clear="all" style="clear: all;">
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -214,7 +212,7 @@
</p>
<p>
-See example 4 at the examples section
+See example 6 at the examples section
for an illustration of use of Boost.Flyweight serialization capabilities.
</p>
@@ -254,15 +252,15 @@
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight tutorial" border="0"><br>
Boost.Flyweight tutorial
</a></div>
-<div class="next_link"><a href="configuration.html"><img src="../next.gif" alt="configuring Boost.Flyweight" border="0"><br>
-Configuring Boost.Flyweight
+<div class="next_link"><a href="key_value.html"><img src="../next.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div><br clear="all" style="clear: all;">
<br>
-<p>Revised November 12th 2007</p>
+<p>Revised August 12th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -6,17 +6,17 @@
<title>Boost.Flyweight Documentation - Tutorial - Configuring Boost.Flyweight</title>
<link rel="stylesheet" href="../style.css" type="text/css">
<link rel="start" href="../index.html">
-<link rel="prev" href="basics.html">
+<link rel="prev" href="key_value.html">
<link rel="up" href="index.html">
<link rel="next" href="extension.html">
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tutorial: Configuring Boost.Flyweight</h1>
-<div class="prev_link"><a href="basics.html"><img src="../prev.gif" alt="basics" border="0"><br>
-Basics
+<div class="prev_link"><a href="key_value.html"><img src="../prev.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div>
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight tutorial" border="0"><br>
Boost.Flyweight tutorial
@@ -27,8 +27,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -41,6 +39,7 @@
<li>Tagging</li>
<li>Factory specification
<ul>
+ <li>Types involved in the configuration of factories</li>
<li>hashed_factory
</li>
<li>set_factory
</li>
<li>assoc_container_factory
</li>
@@ -80,7 +79,7 @@
<code>flyweight</code> objects refer to.
</li>
<li>Mechanism of instantiation of the flyweight factory.</li>
- <li>Internal synchronization mecanism for access to
+ <li>Internal synchronization mechanism for access to
the internal factory in multithreaded environments.</li>
<li>Tracking policy controlling how a value stored in the
factory is handled when all the flyweight objects associated to it are
@@ -191,6 +190,28 @@
accept their own template arguments to customize each factory.
</p>
+<h3><a name="factory_types">Types involved in the configuration of factories</a></h3>
+
+<p>
+A given <code>flyweight</code> instantiation has associated
+<code>flyweight::key_type</code>
+and <code>flyweight::value_type</code> types (which are equal in the case
+of regular flyweights or different if <a href="key_value.html">key-value
+flyweights</a>
+are used). Also, there is an internal <code>Entry</code> type which
+corresponds to the type of the objects actually stored in the factory:
+<code>Entry</code> contains the shared <code>value_type</code> objects
+of <code>flyweight</code> as well a some internal bookkeeping information;
+also, <code>Entry</code> is implicitly convertible to
+<code>const key_type&</code>, so that factories can rely on
+<code>key_type</code> to look up <code>Entrie</code>s. Since
+<code>Entry</code> is internal to the implementation of <code>flyweight</code>,
+it cannot be directly referred to by the user in the configuration of
+factories. Instead, the proxy
+placeholder
+type <code>boost::mpl::_1</code> can be used.
+</p>
+
<h3><a name="hashed_factory"><code>hashed_factory</code></a></h3>
<blockquote>
@@ -224,7 +245,32 @@
<blockquote><pre>
<span class=identifier>flyweight</span><span class=special><</span>
<span class=identifier>T</span><span class=special>,</span>
- <span class=identifier>hashed_factory</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>hash</span><span class=special><</span><span class=identifier>T</span><span class=special>>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>equal_to</span><span class=special><</span><span class=identifier>T</span><span class=special>>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span><span class=identifier>T</span><span class=special>></span> <span class=special>></span>
+ <span class=identifier>hashed_factory</span><span class=special><</span>
+ <span class=identifier>boost</span><span class=special>::</span><span class=identifier>hash</span><span class=special><</span><span class=identifier>key_value</span><span class=special>>,</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>equal_to</span><span class=special><</span><span class=identifier>key_value</span><span class=special>>,</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>></span>
+ <span class=special>></span>
+<span class=special>></span>
+</pre></blockquote>
+
+<p>
+where <code>key_type</code> is the key type of the flyweight and
+<code>boost::mpl::_1</code>, as explained above, stands for the
+internal <code>Entry</code> type of the elements stored in the factory.
+Suppose we would like to configure <code>hashed_factory</code> for
+a <code>std::string</code> flyweight with
+a special hash predicate <code>special_hash</code> and a custom allocator
+<code>custom_allocator</code>; this would be specified as follows:
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special><</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier>hashed_factory</span><span class=special><</span>
+ <span class=identifier>special_hash</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>>,</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>equal_to</span><span class=special><</span><span class=identifier>key_value</span><span class=special>>,</span>
+ <span class=identifier>custom_allocator</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>></span>
+ <span class=special>></span>
<span class=special>></span>
</pre></blockquote>
@@ -259,7 +305,7 @@
<blockquote><pre>
<span class=identifier>flyweight</span><span class=special><</span>
<span class=identifier>T</span><span class=special>,</span>
- <span class=identifier>set_factory</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>T</span><span class=special>>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span><span class=identifier>T</span><span class=special>></span> <span class=special>></span>
+ <span class=identifier>set_factory</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>key_type</span><span class=special>>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>></span> <span class=special>></span>
<span class=special>></span>
</pre></blockquote>
@@ -288,16 +334,17 @@
<a href="../../../mpl/doc/index.html">Boost MPL Library</a>:
<code>ContainerSpecifier</code> must be an
<a href="lambda_expressions.html"><code>MPL Lambda
-Expression</code></a> such that, when invoked with an
-Assignable
-type <code>Q</code> convertible to <code>const T&</code>, where <code>T</code>
-is the underlying type of the <code>flyweight</code>, it produces the type of
-a container of <code>Q</code> elements satisfying the following
+Expression</code></a> such that, when invoked with the
+types <code>Entry</code> and <code>key_type</code>
+explained above, it produces the type of
+a container of <code>Entry</code> elements satisfying the following
requirements:
<ol>
<li>The container type must be a model of
<a href="http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html"><code>Unique
- Associative Container</code></a>.
+ Associative Container</code></a> where equivalence of <code>Entry</code>s
+ is determined by the <code>key_type</code> values the entries are convertible
+ to .
</li>
<li>The container must be <i>stable</i>, i.e. its iterators must remain valid
after insert and erase operations. Note that this condition is not met by
@@ -340,19 +387,18 @@
</pre></blockquote>
<p>
-<code>mpl::_1</code> is a so-called MPL
-placeholder
-and its purpose is to mark the location where it appears as an available
-"slot" to be filled in with a concrete type later on --in our case,
-the substitution is done internally by Boost.Flyweight. Note that we have not
+As has been explained, <code>mpl::_1</code> is a so-called MPL
+placeholder standing as a "slot" to be replaced with
+<code>Entry</code> by the internal machinery of Boost.Flyweight.
+Note that we have not
relied on the default argument of <code>ultrafast_set</code> for
<code>Compare</code> and instead we have provided a fixed
instantiation for <code>std::string</code>: this is so because
requirements state that the type with which <code>ContainerSpecifier</code>
-will be filled in internally is convertible to <code>const T&</code>
-(here <code>const std::string&</code>), but there is no guarantee that that type
-itself is less-comparable or for that matter has any arbitrary
-property that the container might demand. On the other hand,
+will be filled in internally is convertible to <code>const key_type&</code>
+(here <code>const std::string&</code>), and it is based on
+<code>key_type</code> that lookup and equivalence of entries
+should be determined. On the other hand,
the default argument for the <code>Allocator</code> parameter works
just fine, as is more apparent if we write it down explicitly:
</p>
@@ -466,6 +512,13 @@
<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span><span class=identifier><b>intermodule_holder</b></span><span class=special>></span> <span class=identifier>flyweight_string</span><span class=special>;</span>
</pre></blockquote>
+<p>
+<code>intermodule_holder</code> is considerably more onerous than
+<code>static_holder</code> in terms of compilation times and
+introduces a non-negligible overhead at program start-up, so its use
+should be reserved to the situations where it is really necessary.
+</p>
+
<h2><a name="locking">Locking policies</a></h2>
@@ -546,7 +599,7 @@
advantages and drawbacks. The benefits are:
<ul>
<li>Non-tracked flyweight objects are faster to pass around than refcounted ones.</li>
- <li>There is some in some reduction in memory usage due to the
+ <li>There is some reduction in memory usage due to the
absence of reference counters.</li>
</ul>
whereas potential drawbacks of using <code>no_tracking</code> include:
@@ -562,8 +615,8 @@
<hr>
-<div class="prev_link"><a href="basics.html"><img src="../prev.gif" alt="basics" border="0"><br>
-Basics
+<div class="prev_link"><a href="key_value.html"><img src="../prev.gif" alt="key-value flyweights" border="0"><br>
+Key-value flyweights
</a></div>
<div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight tutorial" border="0"><br>
Boost.Flyweight tutorial
@@ -574,9 +627,9 @@
<br>
-<p>Revised November 29th 2007</p>
+<p>Revised August 14th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tutorial: Extending Boost.Flyweight</h1>
<div class="prev_link"><a href="configuration.html"><img src="../prev.gif" alt="configuring Boost.Flyweight" border="0"><br>
@@ -27,8 +27,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -82,7 +80,7 @@
<blockquote><pre>
<span class=comment>// example of a possible factory class template</span>
-<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>></span>
+<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Key</span><span class=special>></span>
<span class=keyword>class</span> <span class=identifier>custom_factory_class</span>
<span class=special>{</span>
<span class=keyword>public</span><span class=special>:</span>
@@ -95,18 +93,19 @@
</pre></blockquote>
<p>
-Factories are parameterized by <code>Entry</code> and <code>Value</code>:
+Factories are parameterized by <code>Entry</code> and <code>Key</code>:
the first is the type of the objects stored, while the second is the public
-type on which <code>flyweight</code> operates (e.g. the <code>std::string</code>
-in <code>flyweight<std::string></code>). An entry holds a member of type
-<code>Value</code> as well as internal bookkeeping information, but from the
+key type on which <code>flyweight</code> operates (e.g. the <code>std::string</code>
+in <code>flyweight<std::string></code> or
+<code>flyweight<key_value<std::string,texture> ></code>). An entry holds a
+shared value to which flyweight objects are associated as well as internal bookkeeping information, but from the
point of view of the factory, though, the only fact known about <code>Entry</code>
-is that it is implicitly convertible to <code>const Value&</code>, and it is
-based on their associated <code>Value</code> that entries are to be considered
+is that it is implicitly convertible to <code>const Key&</code>, and it is
+based on their associated <code>Key</code> that entries are to be considered
equivalent or not. The factory <code>insert()</code>
member function locates a previously stored entry whose
-associated <code>Value</code> is equivalent to that of the <code>Entry</code>
-object being passed (for some equivalence relation on <code>Value</code> germane to
+associated <code>Key</code> is equivalent to that of the <code>Entry</code>
+object being passed (for some equivalence relation on <code>Key</code> germane to
the factory), or stores the new entry if no equivalent one is found. A
<code>handle_type</code> to the equivalent or newly inserted entry is returned;
this <code>handle_type</code> is a token for further access to an entry via
@@ -124,10 +123,10 @@
functionality on a regular <code>std::set</code>:
<blockquote><pre>
-<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Value</span><span class=special>></span>
+<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Key</span><span class=special>></span>
<span class=keyword>class</span> <span class=identifier>verbose_factory_class</span>
<span class=special>{</span>
- <span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>set</span><span class=special><</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>Value</span><span class=special>></span> <span class=special>></span> <span class=identifier>store_type</span><span class=special>;</span>
+ <span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>set</span><span class=special><</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>Key</span><span class=special>></span> <span class=special>></span> <span class=identifier>store_type</span><span class=special>;</span>
<span class=identifier>store_type</span> <span class=identifier>store</span><span class=special>;</span>
@@ -138,17 +137,17 @@
<span class=special>{</span>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special><</span><span class=identifier>handle_type</span><span class=special>,</span> <span class=keyword>bool</span><span class=special>></span> <span class=identifier>p</span><span class=special>=</span><span class=identifier>store</span><span class=special>.</span><span class=identifier>insert</span><span class=special>(</span><span class=identifier>x</span><span class=special>);</span>
<span class=keyword>if</span><span class=special>(</span><span class=identifier>p</span><span class=special>.</span><span class=identifier>second</span><span class=special>){</span> <span class=comment>/* new entry */</span>
- <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"new: "</span><span class=special><<(</span><span class=keyword>const</span> <span class=identifier>Value</span><span class=special>&)</span><span class=identifier>x</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"new: "</span><span class=special><<(</span><span class=keyword>const</span> <span class=identifier>Key</span><span class=special>&)</span><span class=identifier>x</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>else</span><span class=special>{</span> <span class=comment>/* existing entry */</span>
- <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"hit: "</span><span class=special><<(</span><span class=keyword>const</span> <span class=identifier>Value</span><span class=special>&)</span><span class=identifier>x</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"hit: "</span><span class=special><<(</span><span class=keyword>const</span> <span class=identifier>Key</span><span class=special>&)</span><span class=identifier>x</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>return</span> <span class=identifier>p</span><span class=special>.</span><span class=identifier>first</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>void</span> <span class=identifier>erase</span><span class=special>(</span><span class=identifier>handle_type</span> <span class=identifier>h</span><span class=special>)</span>
<span class=special>{</span>
- <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"del: "</span><span class=special><<(</span><span class=keyword>const</span> <span class=identifier>Value</span><span class=special>&)*</span><span class=identifier>h</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special><<</span><span class=string>"del: "</span><span class=special><<(</span><span class=keyword>const</span> <span class=identifier>Key</span><span class=special>&)*</span><span class=identifier>h</span><span class=special><<</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;</span>
<span class=identifier>store</span><span class=special>.</span><span class=identifier>erase</span><span class=special>(</span><span class=identifier>h</span><span class=special>);</span>
<span class=special>}</span>
@@ -164,18 +163,18 @@
<ul>
<li>
Note that the factory is parameterized by <code>Entry</code>
- and <code>Value</code>, as these types are provided internally by Boost.Flyweight
+ and <code>Key</code>, as these types are provided internally by Boost.Flyweight
when the factory is instantiated as part of the machinery of <code>flyeight</code>;
- but there is nothing to prevent us from having more template parameters for
+ but there is nothing to prevent us from having more template parameters for
finer configuration of the factory type: for instance, we could extend
<code>verbose_factory_class</code> to accept some comparison predicate rather than
- the default <code>std::less<Value></code>, or to specify the allocator
+ the default <code>std::less<Key></code>, or to specify the allocator
used by the internal <code>std::set</code>.
</li>
<li>
- The fact that <code>Entry</code> is convertible to <code>const Value&</code>
+ The fact that <code>Entry</code> is convertible to <code>const Key&</code>
(which is about the only property known about <code>Entry</code>) is
- exploited in the specification of <code>std::less<Value></code> as
+ exploited in the specification of <code>std::less<Key></code> as
the comparison predicate for the <code>std::set</code> of <code>Entry</code>s
used as the internal repository.
</li>
@@ -192,7 +191,7 @@
A factory specifier is a
<a href="lambda_expressions.html"><code>Lambda
Expression</code></a> accepting the two argument types <code>Entry</code>
-and <code>Value</code> and returning the corresponding factory class:
+and <code>Key</code> and returning the corresponding factory class:
</p>
<blockquote><pre>
@@ -200,10 +199,10 @@
<span class=keyword>struct</span> <span class=identifier>custom_factory_specifier</span>
<span class=special>{</span>
- <span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>></span>
+ <span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span><span class=special>></span>
<span class=keyword>struct</span> <span class=identifier>apply</span>
<span class=special>{</span>
- <span class=keyword>typedef</span> <span class=identifier>custom_factory_class</span><span class=special><</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>></span> <span class=identifier>type</span><span class=special>;</span>
+ <span class=keyword>typedef</span> <span class=identifier>custom_factory_class</span><span class=special><</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span><span class=special>></span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>}</span>
<span class=special>};</span>
@@ -230,10 +229,10 @@
<span class=keyword>struct</span> <span class=identifier>custom_factory_specifier</span><span class=special>:</span> <span class=identifier><b>factory_marker</b></span>
<span class=special>{</span>
- <span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>></span>
+ <span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span><span class=special>></span>
<span class=keyword>struct</span> <span class=identifier>apply</span>
<span class=special>{</span>
- <span class=keyword>typedef</span> <span class=identifier>custom_factory_class</span><span class=special><</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>></span> <span class=identifier>type</span><span class=special>;</span>
+ <span class=keyword>typedef</span> <span class=identifier>custom_factory_class</span><span class=special><</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Key</span><span class=special>></span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>}</span>
<span class=special>};</span>
</pre></blockquote>
@@ -271,7 +270,7 @@
</p>
<p>
-Example 6 in the examples section develops
+Example 8 in the examples section develops
in full the <code>verbose_factory_class</code> case sketched above.
</p>
@@ -373,7 +372,7 @@
<p>
where <code>lock_type</code> is used to acquire/release mutexes according to
-the <code>scoped lock</code> idiom:
+the <i>scoped lock</i> idiom:
</p>
<blockquote><pre>
@@ -448,14 +447,22 @@
<ul>
<li><code>Tracking::entry_type</code> is a
<a href="lambda_expressions.html"><code>Lambda
- Expression</code></a> accepting a type <code>Value</code> and returning
- a type implicitly convertible to <code>const Value&</code>.
- We saw when reviewing the factory requirements that
- the entries stored internally by <code>flyweight<T></code>
- are not <code>T</code> objects, but rather some undisclosed type
- convertible to <code>const T&</code>: a tracking policy can make
- use of this leeway to store internal tracking information, or if this
- is not needed it can just return <code>Value</code>.
+ Expression</code></a> accepting two different types named
+ <code>Value</code> and <code>Key</code> such that
+ <code>Value</code> is implicitly convertible to
+ <code>const Key&</code>. The expression is expected
+ to return
+ a type implicitly convertible to both <code>const Value&</code>
+ and <code>const Key&</code>.
+ <code>Tracking::entry_type</code> corresponds to the actual
+ type of the entries stored into the
+ flyweight factory:
+ by allowing the tracking policy to take part on the definition
+ of this type it is possible for the policy to add internal
+ tracking information to the entry data in case this is needed.
+ If no additional information is required,
+ the tracking policy can simply return <code>Value</code> as its
+ <code>Tracking::entry_type</code> type.
</li>
<li>
The binary <a href="lambda_expressions.html"><code>Lambda
@@ -470,9 +477,12 @@
</li>
</ul>
So, in order to define the factory of some instantiation
-<code>flyweight<Value,...></code>, <code>Tracking::entry_type</code>
-is invoked with <code>Value</code> to obtain the entry type for the factory,
-and then <code>Tracking::handle_type</code> is fed an internal handle
+<code>fw_t</code> of <code>flyweight</code>, <code>Tracking::entry_type</code>
+is invoked with an internal type <code>Value</code> implicitly convertible
+to <code>const fw_t::key_type&</code> to obtain the entry type for the factory,
+which must be convertible to both <code>const Value&</code> and
+<code>const fw_t::key_type&</code>.
+Then, <code>Tracking::handle_type</code> is fed an internal handle
type and a tracking policy helper to produce the factory handle type.
The observant reader might have detected an apparent circularity:
<code>Tracking::handle_type</code> produces the handle type of
@@ -480,7 +490,7 @@
that grants access to the factory being defined!
The solution to this riddle comes from the realization of the fact that
<code>TrackingHandler</code> is an <i>incomplete
-types</i> by the time it is passed to <code>Tracking::handle_type</code>:
+type</i> by the time it is passed to <code>Tracking::handle_type</code>:
only when <code>Handle</code> is instantiated at a later stage will this
type be complete.
</p>
@@ -539,9 +549,9 @@
<br>
-<p>Revised November 29th 2007</p>
+<p>Revised September 1st 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/tutorial/index.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tutorial/index.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/index.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tutorial</h1>
<div class="prev_link"><a href="../index.html"><img src="../prev.gif" alt="index" border="0"><br>
@@ -27,14 +27,14 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
<li>Rationale</li>
<li>Namespace</li>
+ <li>Guide to the reader</li>
<li>Basics</li>
+ <li>Key-value flyweights</li>
<li>Configuring Boost.Flyweight</li>
<li>Extending Boost.Flyweight</li>
<li>Technical issues</li>
@@ -88,7 +88,7 @@
view of application design, but when it comes to implementation extrinsic
information has no impact on the overall flyweight scheme. So,
Boost.Flyweight assumes that the type onto which the library operates
-entirely consists of intrinsic information: this enables a particularly
+entirely consists of intrinsic information: this allows for a particularly
appealing realization of the idiom in C++ in which
<code>flyweight<T></code> is an opaque type convertible to
<code>const T&</code>.
@@ -125,6 +125,24 @@
<span class=keyword>using</span> <span class=keyword>namespace</span> <span class=special>::</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>flyweights</span><span class=special>;</span>
</pre></blockquote>
+<h2><a name="guide">Guide to the reader</a></h2>
+
+<p>
+Although Boost.Flyweight features an extensive customization
+framework controlling many internal implementation aspects, the library is designed
+in such a way that most users need not be concerned about or
+even aware of the underlying complexity. Learning to use Boost.Flyweight
+as an off-the-shelf component can be acomplished merely by reading
+the basics section and skimming through the
+part on key-value flyweights, the section on flyweight type
+tagging and the discussion of some
+technical issues. The
+configuration section teaches how to fine tune the
+different internal components of the library. Only very advanced usage
+scenarios will require implementing user-provided pluggable components:
+this is covered on the extension section.
+</p>
+
<hr>
<div class="prev_link"><a href="../index.html"><img src="../prev.gif" alt="index" border="0"><br>
@@ -139,9 +157,9 @@
<br>
-<p>Revised November 26th 2007</p>
+<p>Revised August 13th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tutorial Annex: MPL lambda expressions</h1>
<div class="prev_link"><a href="technical.html"><img src="../prev.gif" alt="technical issues" border="0"><br>
@@ -27,12 +27,10 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<p>This short introduction to lambda expressions is meant for readers unfamiliar
with the Boost MPL Library who
want to rapidly acquire a working knowledge of the basic concepts for the purposes
-of using them in Boost.Flyweight. Please refer to Boost.MPL documentation
+of using them in Boost.Flyweight. Please refer to the Boost.MPL documentation
for further information beyond these introductory notes.
</p>
@@ -86,7 +84,7 @@
<span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>,</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_2</span><span class=special>></span> <span class=identifier>foo_specifier</span><span class=special>;</span>
</pre></blockquote>
Note that, in this case, <code>foo_specifier</code> is a concrete type, much
- as <code>int</code> or <code>std::set<std::string></code> are; yet,
+ as <code>int</code> or <code>std::set<std::string></code> are; yet,
MPL internal mechanisms are able to detect that this type has been gotten
from instantiating a class template with placeholders <code>boost::mpl::_1</code>
and <code>boost::mpl::_2</code> and take these placeholders as slots to
@@ -117,17 +115,20 @@
</pre></blockquote>
<p>
-trasforming them:
+passing placeholder subexpressions as arguments to the overall expression:
</p>
<blockquote><pre>
<span class=keyword>struct</span> <span class=identifier>foo_specifier</span>
<span class=special>{</span>
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Arg1</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg2</span><span class=special>></span>
- <span class=keyword>struct</span> <span class=identifier>apply</span><span class=special>{</span><span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>Arg1</span><span class=special>*,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>Arg2</span><span class=special>></span> <span class=special>></span> <span class=identifier>type</span><span class=special>;};</span>
+ <span class=keyword>struct</span> <span class=identifier>apply</span><span class=special>{</span><span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>shared_ptr</span><span class=special><</span><span class=identifier>Arg1</span><span class=special>>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>Arg2</span><span class=special>></span> <span class=special>></span> <span class=identifier>type</span><span class=special>;};</span>
<span class=special>};</span>
-<span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>*,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_2</span><span class=special>></span> <span class=special>></span> <span class=identifier>foo_specifier</span><span class=special>;</span>
+<span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span>
+ <span class=identifier>boost</span><span class=special>::</span><span class=identifier>shared_ptr</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>>,</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_2</span><span class=special>></span>
+<span class=special>></span> <span class=identifier>foo_specifier</span><span class=special>;</span>
</pre></blockquote>
<p>
@@ -139,10 +140,10 @@
<span class=keyword>struct</span> <span class=identifier>foo_specifier</span>
<span class=special>{</span>
<span class=keyword>template</span><span class=special><</span><span class=keyword>typename</span> <span class=identifier>Arg1</span><span class=special>></span>
- <span class=keyword>struct</span> <span class=identifier>apply</span><span class=special>{</span><span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>Arg1</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>*></span> <span class=identifier>type</span><span class=special>;};</span>
+ <span class=keyword>struct</span> <span class=identifier>apply</span><span class=special>{</span><span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>Arg1</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>Arg1</span><span class=special>></span> <span class=identifier>type</span><span class=special>;};</span>
<span class=special>};</span>
-<span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>*></span> <span class=special>></span> <span class=identifier>foo_specifier</span><span class=special>;</span>
+<span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special><</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>></span> <span class=special>></span> <span class=identifier>foo_specifier</span><span class=special>;</span>
<span class=keyword>struct</span> <span class=identifier>foo_specifier</span>
<span class=special>{</span>
@@ -167,9 +168,9 @@
<br>
-<p>Revised November 27th 2007</p>
+<p>Revised August 13th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/doc/tutorial/technical.html
==============================================================================
--- sandbox/flyweight/libs/flyweight/doc/tutorial/technical.html (original)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/technical.html 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -12,7 +12,7 @@
</head>
<body>
-<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+<h1><img src="../../../../boost.png" alt="Boost logo" align=
"middle" width="277" height="86">Boost.Flyweight Tutorial: Technical issues</h1>
<div class="prev_link"><a href="extension.html"><img src="../prev.gif" alt="extending Boost.Flyweight" border="0"><br>
@@ -27,8 +27,6 @@
<hr>
-<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
-
<h2>Contents</h2>
<ul>
@@ -56,7 +54,7 @@
usage of the class, for instance if we declare a global
<code>static flyweight<T></code> object. This covers the vast
majority of usage cases in a transparent manner, but there are
-exotic scenarios where the automatic static data initialization
+some scenarios where the automatic static data initialization
policy of Boost.Flyweight can fail:
</p>
@@ -118,21 +116,54 @@
</p>
<p>
-In some settings, particularly when defining global objects, calling
-the function <code>flyweight<T>::init</code> can be a little
-cumbersome. <code>flyweight<T></code> provides a nested type
-<code>initializer</code> to do that job for us:
+The following is another example where the default static initialization
+provided by Boost.Flyweight can fail:
</p>
<blockquote><pre>
-<span class=keyword>class</span> <span class=identifier>thread_pool</span>
+<span class=keyword>static</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=identifier>flyweight</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>></span> <span class=special>></span> <span class=identifier>v</span><span class=special>;</span>
+
+<span class=keyword>int</span> <span class=identifier>main</span><span class=special>()</span>
<span class=special>{</span>
- <span class=special>...</span>
-<span class=special>};</span>
+ <span class=comment>// use v</span>
+<span class=special>}</span>
+</pre></blockquote>
+<p>
+In some environments, the program above fails at termination time with something
+like the following:
+</p>
+
+<blockquote><pre>
+Assertion failed: count()==0, file c:\boost\flyweight\refcounted.hpp, line 55
+</pre></blockquote>
+
+<p>
+What is the problem? Although the type of <code>v</code> involves
+<code>flyweight<std::string></code>, constructing <code>v</code> as an empty vector
+need not create any flyweight object proper; so,
+it is perfectly possible that the static initialization of
+<code>flyweight<std::string></code> happens <i>after</i> the construction
+of <code>v</code>; when this is the case, the static destruction of
+the associated factory will occur <i>before</i> <code>v</code>'s
+destruction, leaving the vector with dangling flyweights.
+Again, the solution consists in explicitly forcing the static instantiation
+of <code>flyweight<std::string></code> before <code>v</code> is
+created. Here, calling
+the function <code>flyweight<std::string>::init</code> is a little
+cumbersome, so we can resort to the utility type
+<code>flyweight<std::string>::initializer</code> to do that job for us:
+</p>
+
+<blockquote><pre>
<span class=comment>// equivalent to calling flyweight<std::string>::init()</span>
-<b><span class=keyword>static</span> <span class=identifier>flyweight</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>>::</span><span class=identifier>initializer</span> <span class=identifier>fwinit</span><span class=special>;</span></b>
-<span class=keyword>static</span> <span class=identifier>thread_pool</span> <span class=identifier>thpool</span><span class=special>;</span>
+<b><span class=keyword>static</span> <span class=identifier>flyweight</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>>::</span><span class=identifier>initializer</span> <span class=identifier>fwinit</span><span class=special>;</span></b>
+<span class=keyword>static</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=identifier>flyweight</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>></span> <span class=special>></span> <span class=identifier>v</span><span class=special>;</span>
+
+<span class=keyword>int</span> <span class=identifier>main</span><span class=special>()</span>
+<span class=special>{</span>
+ <span class=comment>// use v; no dangling flyweights at termination now</span>
+<span class=special>}</span>
</pre></blockquote>
<hr>
@@ -149,9 +180,9 @@
<br>
-<p>Revised November 27th 2007</p>
+<p>Revised August 11th 2008</p>
-<p>© Copyright 2006-2007 Joaquín M López Muñoz.
+<p>© Copyright 2006-2008 Joaquín M López Muñoz.
Distributed under the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: sandbox/flyweight/libs/flyweight/example/Jamfile.v2
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/Jamfile.v2 (original)
+++ sandbox/flyweight/libs/flyweight/example/Jamfile.v2 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
# Boost.Flyweight examples Jamfile
#
-# Copyright 2006-2007 Joaquín M López Muñoz.
+# Copyright 2006-2008 Joaquín M López Muñoz.
# 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)
@@ -22,14 +22,25 @@
: <include>$(BOOST_ROOT)
;
+exe fibonacci
+ : fibonacci.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
exe html
: html.cpp
: <include>$(BOOST_ROOT)
;
+exe key_value
+ : key_value.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
exe perf
: perf.cpp
: <include>$(BOOST_ROOT)
+ : release
;
exe serialization
Modified: sandbox/flyweight/libs/flyweight/example/basic.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/basic.cpp (original)
+++ sandbox/flyweight/libs/flyweight/example/basic.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight basic example.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/example/composite.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/composite.cpp (original)
+++ sandbox/flyweight/libs/flyweight/example/composite.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight example of a composite design.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/example/custom_factory.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/custom_factory.cpp (original)
+++ sandbox/flyweight/libs/flyweight/example/custom_factory.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight example of custom factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -33,14 +33,14 @@
* that for simplicity.
*/
-template<typename Entry,typename Value>
+template<typename Entry,typename Key>
class verbose_factory_class
{
- /* Entry store. Since Entry is implicitly convertible to const Value&,
- * we can directly use std::less<Value> as the comparer for std::set.
+ /* Entry store. Since Entry is implicitly convertible to const Key&,
+ * we can directly use std::less<Key> as the comparer for std::set.
*/
- typedef std::set<Entry,std::less<Value> > store_type;
+ typedef std::set<Entry,std::less<Key> > store_type;
store_type store;
@@ -53,17 +53,17 @@
std::pair<handle_type, bool> p=store.insert(x);
if(p.second){ /* new entry */
- std::cout<<"new: "<<(const Value&)x<<std::endl;
+ std::cout<<"new: "<<(const Key&)x<<std::endl;
}
else{ /* existing entry */
- std::cout<<"hit: "<<(const Value&)x<<std::endl;
+ std::cout<<"hit: "<<(const Key&)x<<std::endl;
}
return p.first;
}
void erase(handle_type h)
{
- std::cout<<"del: "<<(const Value&)*h<<std::endl;
+ std::cout<<"del: "<<(const Key&)*h<<std::endl;
store.erase(h);
}
@@ -81,10 +81,10 @@
struct verbose_factory: factory_marker
{
- template<typename Entry,typename Value>
+ template<typename Entry,typename Key>
struct apply
{
- typedef verbose_factory_class<Entry,Value> type;
+ typedef verbose_factory_class<Entry,Key> type;
} ;
};
Modified: sandbox/flyweight/libs/flyweight/example/html.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/html.cpp (original)
+++ sandbox/flyweight/libs/flyweight/example/html.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight example of flyweight-based formatted text processing.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/example/perf.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/perf.cpp (original)
+++ sandbox/flyweight/libs/flyweight/example/perf.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight example of performance comparison.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -15,6 +15,7 @@
#include <boost/flyweight/simple_locking.hpp>
#include <boost/flyweight/refcounted.hpp>
#include <boost/flyweight/no_tracking.hpp>
+#include <boost/mpl/bool.hpp>
#include <boost/tokenizer.hpp>
#include <algorithm>
#include <cstddef>
@@ -22,6 +23,7 @@
#include <ctime>
#include <fstream>
#include <iostream>
+#include <numeric>
#include <sstream>
#include <string>
#include <vector>
@@ -69,18 +71,6 @@
return p;
}
- /* Dinkumware stdlib implementation for MSVC++ 6.0/7.0 relies in this
- * non standard extension to the allocator interface to cope with
- * rebinding problems.
- */
-
- char* _Charalloc(size_type n)
- {
- char* p=new char[n];
- count_allocator_mem+=n;
- return p;
- }
-
void deallocate(void* p,size_type n)
{
count_allocator_mem-=n*sizeof(T);
@@ -118,52 +108,53 @@
char,std::char_traits<char>,count_allocator<char>
> count_string;
-#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
typedef hashed_factory<
- boost::hash<count_string>,
- std::equal_to<count_string>,
- count_allocator<count_string>
+ boost::hash<boost::mpl::_2>,
+ std::equal_to<boost::mpl::_2>,
+ count_allocator<boost::mpl::_1>
> count_hashed_factory;
typedef set_factory<
- std::less<count_string>,
- count_allocator<count_string>
+ std::less<boost::mpl::_2>,
+ count_allocator<boost::mpl::_1>
> count_set_factory;
-#else
-/* Compilers without proper Boost.MPL lambda support (most notably,
- * MSVC++ 6.0/7.0) can't handle the types count_hashed_factory and
- * count_set_factory defined above because of a clash of the
- * nested symbol rebind in count_allocator with Boost.MPL internal
- * machinery. Instead, we can define the types as factory specifiers.
- */
-struct count_hashed_factory:factory_marker
+/* Some additional utilities used by the test routine */
+
+class timer
{
- template<typename Entry,typename Value>
- struct apply
+public:
+ timer(){restart();}
+
+ void restart(){t=std::clock();}
+
+ void time(const char* str)
{
- typedef hashed_factory_class<
- Entry,Value,
- boost::hash<Value>,
- std::equal_to<Value>,
- count_allocator<Entry>
- > type;
- };
+ std::cout<<str<<": "<<(double)(std::clock()-t)/CLOCKS_PER_SEC<<" s\n";
+ }
+
+private:
+ std::clock_t t;
};
-struct count_set_factory:factory_marker
+template<typename T>
+struct is_flyweight:
+ boost::mpl::false_{};
+
+template<
+ typename T,
+ typename Arg1,typename Arg2,typename Arg3,typename Arg4,typename Arg5
+>
+struct is_flyweight<flyweight<T,Arg1,Arg2,Arg3,Arg4,Arg5> >:
+ boost::mpl::true_{};
+
+struct length_adder
{
- template<typename Entry,typename Value>
- struct apply
+ std::size_t operator()(std::size_t n,const count_string& x)const
{
- typedef set_factory_class<
- Entry,Value,
- std::less<Value>,
- count_allocator<Entry>
- > type;
- };
+ return n+x.size();
+ }
};
-#endif
/* Measure time and memory performance for a String, which is assumed
* to be either a plain string type or a string flyweight.
@@ -190,12 +181,12 @@
std::exit(EXIT_FAILURE);
}
- std::clock_t start=std::clock();
-
- /* Tokenize using space and common punctuaction as separators, and
- * keeping the separators.
+ /* Initialization; tokenize using space and common punctuaction as
+ * separators, and keeping the separators.
*/
-
+
+ timer t;
+
tokenizer tok=tokenizer(
char_iterator(ifs),char_iterator(),
boost::char_separator<char>(
@@ -206,14 +197,48 @@
txt.push_back(String(it->c_str()));
}
- /* Do some text handling */
+ t.time("initialization time");
+
+ /* Assignment */
+
+ t.restart();
+
+ count_vector txt2;
+ for(int i=0;i<10;++i){
+ txt2.insert(txt2.end(),txt.begin(),txt.end());
+ }
+
+ t.time("assignment time");
+
+ /* Equality comparison */
+
+ t.restart();
+
+ std::size_t c=0;
+ for(int i=0;i<100;++i){
+ c+=std::count(txt.begin(),txt.end(),txt[c%txt.size()]);
+ }
- std::sort(txt.begin(),txt.end());
- std::random_shuffle(txt.begin(),txt.end());
+ t.time("equality comparison time");
- std::cout<<"Time used: "<<(double)(std::clock()-start)/CLOCKS_PER_SEC
- <<" s\n";
- std::cout<<"Bytes used: "<<count_allocator_mem<<"\n";
+ /* Value access */
+
+ t.restart();
+
+ std::size_t s=0;
+ for(int i=0;i<20;++i){
+ s=std::accumulate(txt2.begin(),txt2.end(),s,length_adder());
+ }
+
+ t.time("value access time");
+
+ std::cout<<"bytes used: "<<count_allocator_mem;
+ if(is_flyweight<String>::value){
+ std::size_t flyweight_mem=(txt.capacity()+txt2.capacity())*sizeof(String);
+ std::cout<<"= flyweights("<<flyweight_mem
+ <<")+values("<<count_allocator_mem-flyweight_mem<<")";
+ }
+ std::cout<<"\n";
}
};
@@ -226,15 +251,6 @@
void (*test)(const std::string&);
};
-/* MSVC++ 6.0/7.0 needs the following explicit instantiations for test<...>
- * to compile correctly.
- */
-
-flyweight<count_string,count_hashed_factory> dummy1;
-flyweight<count_string,count_hashed_factory,no_tracking> dummy2;
-flyweight<count_string,count_set_factory> dummy3;
-flyweight<count_string,count_set_factory,no_tracking> dummy4;
-
test_case test_table[]=
{
{
@@ -259,7 +275,7 @@
}
};
-enum{num_test_cases=sizeof(test_table)/sizeof(test_case)};
+const int num_test_cases=sizeof(test_table)/sizeof(test_case);
int main()
{
Modified: sandbox/flyweight/libs/flyweight/example/serialization.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/example/serialization.cpp (original)
+++ sandbox/flyweight/libs/flyweight/example/serialization.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight example of serialization.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of intermodule_holder.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of intermodule_holder.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_all_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_all_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_all_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test suite.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -27,11 +27,7 @@
test_basic();
test_custom_factory();
test_init();
-
-#if !defined(BOOST_MSVC)||!(BOOST_MSVC<1300)
test_intermodule_holder();
-#endif
-
test_multictor();
test_no_locking();
test_no_tracking();
Modified: sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of assoc_container_factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of assoc_container_factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -16,18 +16,18 @@
#include <boost/flyweight/refcounted.hpp>
#include <boost/flyweight/simple_locking.hpp>
#include <boost/flyweight/static_holder.hpp>
-#include <boost/mpl/aux_/lambda_support.hpp>
-#include "lambda_components.hpp"
+#include <functional>
+#include <set>
#include "test_basic_template.hpp"
using namespace boost::flyweights;
struct reverse_set_specifier
{
- template<typename Entry,typename Value>
+ template<typename Entry,typename Key>
struct apply
{
- typedef std::set<Entry,std::greater<Value> > type;
+ typedef std::set<Entry,std::greater<Key> > type;
};
};
@@ -51,13 +51,10 @@
typedef flyweight<
T,
assoc_container_factory_class<
- lambda_set<
+ std::set<
boost::mpl::_1,
- lambda_greater<boost::mpl::_2>
-
-#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
- ,std::allocator<boost::mpl::_1>
-#endif
+ std::greater<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
>
>
> type;
@@ -66,6 +63,6 @@
void test_assoc_container_factory()
{
- BOOST_FLYWEIGHT_TEST_BASIC(assoc_container_factory_flyweight_specifier1)
- BOOST_FLYWEIGHT_TEST_BASIC(assoc_container_factory_flyweight_specifier2)
+ test_basic_template<assoc_container_factory_flyweight_specifier1>();
+ test_basic_template<assoc_container_factory_flyweight_specifier2>();
}
Modified: sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of assoc_container_factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_basic.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_basic.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_basic.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight basic test.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -12,7 +12,6 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/flyweight.hpp>
-#include "lambda_components.hpp"
#include "test_basic_template.hpp"
using namespace boost::flyweights;
@@ -36,12 +35,8 @@
static_holder_class<boost::mpl::_1>,
hashed_factory_class<
boost::mpl::_1,boost::mpl::_2,
- lambda_hash<boost::mpl::_2>,lambda_equal_to<boost::mpl::_2>
-
-#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
- ,std::allocator<boost::mpl::_1>
-#endif
-
+ boost::hash<boost::mpl::_2>,std::equal_to<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
>,
simple_locking,
refcounted
@@ -57,12 +52,8 @@
typedef flyweight<
T,
hashed_factory<
- lambda_hash<boost::mpl::_2>,lambda_equal_to<boost::mpl::_2>
-
-#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
- ,std::allocator<boost::mpl::_1>
-#endif
-
+ boost::hash<boost::mpl::_2>,std::equal_to<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
>,
tag<int>
> type;
@@ -71,7 +62,7 @@
void test_basic()
{
- BOOST_FLYWEIGHT_TEST_BASIC(basic_flyweight_specifier1)
- BOOST_FLYWEIGHT_TEST_BASIC(basic_flyweight_specifier2)
- BOOST_FLYWEIGHT_TEST_BASIC(basic_flyweight_specifier3)
+ test_basic_template<basic_flyweight_specifier1>();
+ test_basic_template<basic_flyweight_specifier2>();
+ test_basic_template<basic_flyweight_specifier3>();
}
Modified: sandbox/flyweight/libs/flyweight/test/test_basic.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_basic.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_basic.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight basic test.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight basic test.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight basic test template.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -17,9 +17,12 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/lightweight_test.hpp>
+#include <boost/flyweight/key_value.hpp>
#include <boost/mpl/apply.hpp>
+#include <boost/utility/value_init.hpp>
#include <string>
#include <sstream>
+#include "heavy_objects.hpp"
#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
@@ -35,11 +38,14 @@
for(it=first;it!=last;++it){
/* construct/copy/destroy */
- Flyweight f1(*it);
- Flyweight f2;
- Flyweight c1(f1);
- Flyweight c2(static_cast<const Flyweight&>(f2));
- BOOST_TEST((f1==f2)==(f1.get()==value_type()));
+ Flyweight f1(*it);
+ Flyweight f2;
+ Flyweight c1(f1);
+ Flyweight c2(static_cast<const Flyweight&>(f2));
+ value_type v1(*it);
+ boost::value_initialized<value_type> v2;
+ BOOST_TEST(f1.get_key()==*it);
+ BOOST_TEST((f1==f2)==(f1.get()==v2.data()));
BOOST_TEST(f1==c1);
BOOST_TEST(f2==c2);
@@ -54,8 +60,7 @@
/* convertibility to underlying type */
- value_type v1(f1);
- BOOST_TEST(v1==f1.get());
+ BOOST_TEST(f1.get()==v1);
/* identity of reference */
@@ -81,14 +86,47 @@
std::ostringstream oss2;
oss2<<f1.get();
BOOST_TEST(oss1.str()==oss2.str());
+ }
+}
+
+template<typename Flyweight,typename ForwardIterator>
+void test_basic_with_assign_template(
+ ForwardIterator first,ForwardIterator last
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ typedef typename Flyweight::value_type value_type;
+
+ ForwardIterator it;
+
+ test_basic_template<Flyweight>(first,last);
+
+ for(it=first;it!=last;++it){
+ /* value construction */
+
+ value_type v(*it);
+ Flyweight f1(v);
+ Flyweight f2(f1.get());
+ BOOST_TEST(f1.get()==v);
+ BOOST_TEST(f2.get()==v);
+ BOOST_TEST(f1==f2);
+
+ /* value assignment */
+
+ Flyweight f3,f4;
+ f3=v;
+ f4=f1.get();
+ BOOST_TEST(f2.get()==v);
+ BOOST_TEST(f3.get()==v);
+ BOOST_TEST(f2==f3);
+
+ /* specialized algorithms */
+ std::ostringstream oss1;
+ oss1<<f1;
std::istringstream iss1(oss1.str());
- Flyweight f3;
- iss1>>f3;
- std::istringstream iss2(oss2.str());
- value_type v3;
- iss2>>v3;
- BOOST_TEST(f3.get()==v3);
+ Flyweight f5;
+ iss1>>f5;
+ BOOST_TEST(f5==f1);
}
}
@@ -106,8 +144,8 @@
typedef typename Flyweight2::value_type value_type2;
for(;first1!=last1;++first1,++first2){
- value_type1 v1=*first1;
- value_type2 v2=*first2;
+ value_type1 v1=value_type1(*first1);
+ value_type2 v2=value_type2(*first2);
Flyweight1 f1(v1);
Flyweight2 f2(v2);
@@ -152,43 +190,41 @@
FlyweightSpecifier,char
>::type char_flyweight;
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<std::string,texture,from_texture_to_string>
+ >::type texture_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<int,factorization>
+ >::type factorization_flyweight;
+
int ints[]={0,1,1,0,1,2,3,4,3,4,0,0};
- test_basic_template<int_flyweight>(&ints[0],&ints[0]+LENGTHOF(ints));
+ test_basic_with_assign_template<int_flyweight>(
+ &ints[0],&ints[0]+LENGTHOF(ints));
const char* words[]={"hello","boost","flyweight","boost","bye","c++","c++"};
- test_basic_template<string_flyweight>(&words[0],&words[0]+LENGTHOF(words));
+ test_basic_with_assign_template<string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words));
+
+ const char* textures[]={"wood","grass","sand","granite","terracotta"};
+ test_basic_with_assign_template<texture_flyweight>(
+ &textures[0],&textures[0]+LENGTHOF(textures));
+
+ int factorizations[]={1098,102387,90846,2223978};
+ test_basic_template<factorization_flyweight>(
+ &factorizations[0],&factorizations[0]+LENGTHOF(factorizations));
char chars[]={0,2,4,5,1,1,1,3,4,1,1,0};
test_basic_comparison_template<int_flyweight,char_flyweight>(
&ints[0],&ints[0]+LENGTHOF(ints),&chars[0]);
test_basic_comparison_template<string_flyweight,string_flyweight>(
- &words[0],&words[0]+LENGTHOF(words),&words[0]);
-}
+ &words[0],&words[0]+LENGTHOF(words)-1,&words[1]);
-#define BOOST_FLYWEIGHT_TEST_BASIC(FlyweightSpecifier) \
-{ \
- /* Without these explicit instantiations, MSVC++ 6.5/7.0 does not \
- * find some friend operators in certain contexts. \
- */ \
- \
- typedef boost::mpl::apply1< \
- FlyweightSpecifier,int \
- >::type int_flyweight; \
- \
- typedef boost::mpl::apply1< \
- FlyweightSpecifier,std::string \
- >::type string_flyweight; \
- \
- typedef boost::mpl::apply1< \
- FlyweightSpecifier,char \
- >::type char_flyweight; \
- \
- int_flyweight f1;f1=f1; \
- string_flyweight f2;f2=f2; \
- char_flyweight f3;f3=f3; \
- \
- test_basic_template<FlyweightSpecifier>(); \
+ test_basic_comparison_template<texture_flyweight,texture_flyweight>(
+ &textures[0],&textures[0]+LENGTHOF(textures)-1,&textures[1]);
}
#undef LENGTHOF
Modified: sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of a custom factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -25,7 +25,7 @@
* http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/lu_based_containers.html
*/
-template<typename Entry,typename Value>
+template<typename Entry,typename Key>
class lu_factory_class:public factory_marker
{
struct entry_type
@@ -45,7 +45,7 @@
{
handle_type h;
for(h=cont.begin();h!=cont.end();++h){
- if(static_cast<const Value&>(h->x)==static_cast<const Value&>(x)){
+ if(static_cast<const Key&>(h->x)==static_cast<const Key&>(x)){
if(++(h->count)==10){
h->count=0;
cont.splice(cont.begin(),cont,h); /* move to front */
@@ -71,15 +71,15 @@
public:
typedef lu_factory_class type;
- BOOST_MPL_AUX_LAMBDA_SUPPORT(2,lu_factory_class,(Entry,Value))
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2,lu_factory_class,(Entry,Key))
};
struct lu_factory:factory_marker
{
- template<typename Entry,typename Value>
+ template<typename Entry,typename Key>
struct apply
{
- typedef lu_factory_class<Entry,Value> type;
+ typedef lu_factory_class<Entry,Key> type;
};
};
@@ -106,6 +106,6 @@
void test_custom_factory()
{
- BOOST_FLYWEIGHT_TEST_BASIC(custom_factory_flyweight_specifier1)
- BOOST_FLYWEIGHT_TEST_BASIC(custom_factory_flyweight_specifier2)
+ test_basic_template<custom_factory_flyweight_specifier1>();
+ test_basic_template<custom_factory_flyweight_specifier2>();
}
Modified: sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of a custom factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of a custom factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_init.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_init.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_init.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of static data initialization facilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_init.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_init.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_init.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of static data initialization facilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_init_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_init_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_init_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of static data initialization facilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of intermodule_holder.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -26,7 +26,7 @@
void test_intermodule_holder()
{
- BOOST_FLYWEIGHT_TEST_BASIC(intermodule_holder_flyweight_specifier1)
+ test_basic_template<intermodule_holder_flyweight_specifier1>();
intermodule_flyweight_string str=
create_intermodule_flyweight_string("boost");
Modified: sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of intermodule_holder.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of intermodule_holder.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_multictor.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_multictor.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_multictor.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of flyweight forwarding ctors.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -16,7 +16,6 @@
#include <boost/functional/hash.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
-#include "lambda_components.hpp"
#include "test_basic_template.hpp"
using boost::flyweight;
Modified: sandbox/flyweight/libs/flyweight/test/test_multictor.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_multictor.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_multictor.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of flyweight forwarding ctors.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of flyweight forwarding ctors.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of no_locking.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -31,5 +31,5 @@
void test_no_locking()
{
- BOOST_FLYWEIGHT_TEST_BASIC(no_locking_flyweight_specifier)
+ test_basic_template<no_locking_flyweight_specifier>();
}
Modified: sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of no_locking.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of no_locking.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of no_tracking.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -31,5 +31,5 @@
void test_no_tracking()
{
- BOOST_FLYWEIGHT_TEST_BASIC(no_tracking_flyweight_specifier)
+ test_basic_template<no_tracking_flyweight_specifier>();
}
Modified: sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of no_tracking.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of no_tracking.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_serialization.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_serialization.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight of serialization capabilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_serialization.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_serialization.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight of serialization capabilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight of serialization capabilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test template for serialization capabilities.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of set_factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
@@ -16,7 +16,6 @@
#include <boost/flyweight/set_factory.hpp>
#include <boost/flyweight/simple_locking.hpp>
#include <boost/flyweight/static_holder.hpp>
-#include "lambda_components.hpp"
#include "test_basic_template.hpp"
using namespace boost::flyweights;
@@ -40,12 +39,8 @@
static_holder_class<boost::mpl::_1>,
set_factory_class<
boost::mpl::_1,boost::mpl::_2,
- lambda_greater<boost::mpl::_2>
-
-#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
- ,std::allocator<boost::mpl::_1>
-#endif
-
+ std::greater<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
>
> type;
};
@@ -59,12 +54,8 @@
typedef flyweight<
T,
set_factory<
- lambda_greater<boost::mpl::_2>
-
-#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
- ,std::allocator<boost::mpl::_1>
-#endif
-
+ std::greater<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
>,
static_holder_class<boost::mpl::_1>,
tag<char>
@@ -74,7 +65,7 @@
void test_set_factory()
{
- BOOST_FLYWEIGHT_TEST_BASIC(set_factory_flyweight_specifier1)
- BOOST_FLYWEIGHT_TEST_BASIC(set_factory_flyweight_specifier2)
- BOOST_FLYWEIGHT_TEST_BASIC(set_factory_flyweight_specifier3)
+ test_basic_template<set_factory_flyweight_specifier1>();
+ test_basic_template<set_factory_flyweight_specifier2>();
+ test_basic_template<set_factory_flyweight_specifier3>();
}
Modified: sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of set_factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
Modified: sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp
==============================================================================
--- sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp (original)
+++ sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp 2008-09-01 11:52:39 EDT (Mon, 01 Sep 2008)
@@ -1,6 +1,6 @@
/* Boost.Flyweight test of set_factory.
*
- * Copyright 2006-2007 Joaquín M López Muñoz.
+ * 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)
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