Boost logo

Boost-Commit :

From: joaquin_at_[hidden]
Date: 2007-11-12 17:46:29


Author: joaquin
Date: 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
New Revision: 41047
URL: http://svn.boost.org/trac/boost/changeset/41047

Log:
initial commit
Added:
   sandbox/flyweight/
   sandbox/flyweight/boost/
   sandbox/flyweight/boost/flyweight/
   sandbox/flyweight/boost/flyweight.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/
   sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/dyn_template_ctors_def.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/dyn_template_ctors_undef.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/msvc60_template_ctors_def.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/msvc60_template_ctors_undef.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/pp_template_ctors_def.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/pp_template_ctors_undef.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/prevent_eti.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/process_id.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/template_ctors_def.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/detail/template_ctors_undef.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/factory_tag.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/flyweight.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/hashed_factory.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/holder_tag.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/intermodule_holder.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/locking_tag.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/no_locking.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/no_tracking.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/refcounted.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/serialize.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/set_factory.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/simple_locking.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/static_holder.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/tag.hpp (contents, props changed)
   sandbox/flyweight/boost/flyweight/tracking_tag.hpp (contents, props changed)
   sandbox/flyweight/libs/
   sandbox/flyweight/libs/flyweight/
   sandbox/flyweight/libs/flyweight/doc/
   sandbox/flyweight/libs/flyweight/doc/acknowledgements.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/examples.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/html.png (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/index.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/next.gif (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/prev.gif (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/
   sandbox/flyweight/libs/flyweight/doc/reference/factories.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/holders.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/index.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/locking.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/tags.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/reference/tracking.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/style.css (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/tutorial/
   sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/tutorial/flyweight_rep.png (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/tutorial/index.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/doc/up.gif (contents, props changed)
   sandbox/flyweight/libs/flyweight/example/
   sandbox/flyweight/libs/flyweight/example/Jamfile.v2 (contents, props changed)
   sandbox/flyweight/libs/flyweight/example/basic.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/example/composite.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/example/html.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/example/perf.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/example/serialization.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/index.html (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/
   sandbox/flyweight/libs/flyweight/test/Jamfile.v2 (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/lambda_components.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_all_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_basic.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_basic.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_multictor.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_multictor.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_serialization.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_serialization.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp (contents, props changed)
   sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp (contents, props changed)

Added: sandbox/flyweight/boost/flyweight.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,22 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_HPP
+#define BOOST_FLYWEIGHT_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/static_holder.hpp>
+
+#endif

Added: sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/assoc_container_factory.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,77 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_ASSOC_CONTAINER_FACTORY_HPP
+#define BOOST_FLYWEIGHT_ASSOC_CONTAINER_FACTORY_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/assoc_container_factory_fwd.hpp>
+#include <boost/flyweight/factory_tag.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+/* Factory class using a given associative container.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+template<typename Container>
+class assoc_container_factory_class:public factory_marker
+{
+public:
+ typedef typename Container::iterator handle_type;
+ typedef typename Container::value_type entry_type;
+
+ handle_type insert(const entry_type& x)
+ {
+ return cont.insert(x).first;
+ }
+
+ void erase(handle_type h)
+ {
+ cont.erase(h);
+ }
+
+ const entry_type& entry(handle_type h){return *h;}
+
+private:
+ Container cont;
+
+public:
+ typedef assoc_container_factory_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,assoc_container_factory_class,(Container))
+};
+
+/* assoc_container_factory_class specifier */
+
+template<
+ typename ContainerSpecifier
+ BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
+>
+struct assoc_container_factory:factory_marker
+{
+ template<typename Entry,typename Value>
+ struct apply
+ {
+ typedef assoc_container_factory_class<
+ typename mpl::apply2<ContainerSpecifier,Entry,Value>::type
+ > type;
+ };
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/assoc_container_factory_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,35 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_ASSOC_CONTAINER_FACTORY_FWD_HPP
+#define BOOST_FLYWEIGHT_ASSOC_CONTAINER_FACTORY_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/flyweight/detail/not_placeholder_expr.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+template<typename Container>
+class assoc_container_factory_class;
+
+template<
+ typename ContainerSpecifier
+ BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION
+>
+struct assoc_container_factory;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/archive_constructed.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,79 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/multi_index for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_ARCHIVE_CONSTRUCTED_HPP
+#define BOOST_FLYWEIGHT_DETAIL_ARCHIVE_CONSTRUCTED_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/no_exceptions_support.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/serialization/serialization.hpp>
+#include <boost/type_traits/aligned_storage.hpp>
+#include <boost/type_traits/alignment_of.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+/* constructs a stack-based object from a serialization archive */
+
+template<typename T>
+struct archive_constructed:private noncopyable
+{
+ template<class Archive>
+ archive_constructed(Archive& ar,const unsigned int version)
+ {
+ serialization::load_construct_data_adl(ar,&get(),version);
+ BOOST_TRY{
+ ar>>get();
+ }
+ BOOST_CATCH(...){
+ (&get())->~T();
+ BOOST_RETHROW;
+ }
+ BOOST_CATCH_END
+ }
+
+ template<class Archive>
+ archive_constructed(const char* name,Archive& ar,const unsigned int version)
+ {
+ serialization::load_construct_data_adl(ar,&get(),version);
+ BOOST_TRY{
+ ar>>serialization::make_nvp(name,get());
+ }
+ BOOST_CATCH(...){
+ (&get())->~T();
+ BOOST_RETHROW;
+ }
+ BOOST_CATCH_END
+ }
+
+ ~archive_constructed()
+ {
+ (&get())->~T();
+ }
+
+ T& get(){return *static_cast<T*>(static_cast<void*>(&space));}
+
+private:
+ typename aligned_storage<sizeof(T),alignment_of<T>::value>::type space;
+};
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/dyn_template_ctors_def.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/dyn_template_ctors_def.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,64 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_DYN_TEMPLATE_CTORS_DEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_DYN_TEMPLATE_CTORS_DEF_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/preprocessor/arithmetic/add.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/seq/elem.hpp>
+#include <boost/preprocessor/seq/for_each_product.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+
+#define BOOST_FLYWEIGHT_CONST(b) BOOST_PP_CAT(BOOST_FLYWEIGHT_CONST,b)
+#define BOOST_FLYWEIGHT_CONST0
+#define BOOST_FLYWEIGHT_CONST1 const
+
+/* if mask[n]==0 --> Tn& tn
+ * if mask[n]==1 --> const Tn& tn
+ */
+
+#define BOOST_FLYWEIGHT_CTOR_ARG(z,n,mask) \
+BOOST_FLYWEIGHT_CONST(BOOST_PP_SEQ_ELEM(n,mask)) \
+BOOST_PP_CAT(T,n)& BOOST_PP_CAT(t,n)
+
+/* flyweight template ctor accepting size(mask) args, where the template
+ * args are marked const or not according to the given mask (a seq of 0 or 1)
+ */
+
+#define BOOST_FLYWEIGHT_CTOR(r,mask) \
+template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(mask),typename T)> \
+explicit flyweight( \
+ BOOST_PP_ENUM(BOOST_PP_SEQ_SIZE(mask),BOOST_FLYWEIGHT_CTOR_ARG,mask)): \
+ h(core::insert( \
+ T(BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(mask),t)))) \
+{}
+
+#define BOOST_FLYWEIGHT_01(z,n,_) ((0)(1))
+
+/* Perfect forwarding template ctors for flyweight accepting 1 to n args */
+
+#define BOOST_FLYWEIGHT_CTORS_N(z,n,_) \
+BOOST_PP_SEQ_FOR_EACH_PRODUCT( \
+ BOOST_FLYWEIGHT_CTOR, \
+ BOOST_PP_REPEAT(n,BOOST_FLYWEIGHT_01,~))
+
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_PP_REPEAT_FROM_TO( \
+ 1,BOOST_PP_ADD(BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS,1), \
+ BOOST_FLYWEIGHT_CTORS_N,~)
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/dyn_template_ctors_undef.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/dyn_template_ctors_undef.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,24 @@
+/* Copyright 2006 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_DYN_TEMPLATE_CTORS_UNDEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_DYN_TEMPLATE_CTORS_UNDEF_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#undef BOOST_FLYWEIGHT_CTORS
+#undef BOOST_FLYWEIGHT_01
+#undef BOOST_FLYWEIGHT_CTOR
+#undef BOOST_FLYWEIGHT_CTOR_ARG
+#undef BOOST_FLYWEIGHT_CONST1
+#undef BOOST_FLYWEIGHT_CONST0
+#undef BOOST_FLYWEIGHT_CONST
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/flyweight_core.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,176 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_FLYWEIGHT_CORE_HPP
+#define BOOST_FLYWEIGHT_DETAIL_FLYWEIGHT_CORE_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+#include <boost/flyweight/detail/handle_factory_adaptor.hpp>
+#include <boost/flyweight/detail/prevent_eti.hpp>
+#include <boost/mpl/apply.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
+#pragma warning(push)
+#pragma warning(disable:4101) /* unreferenced local vars */
+#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.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+template<
+ typename Value,typename Tag,typename TrackingPolicy,
+ typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
+>
+class flyweight_core;
+
+template<
+ typename Value,typename Tag,typename TrackingPolicy,
+ typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
+>
+struct flyweight_core_tracking_helper
+{
+private:
+ typedef flyweight_core<
+ Value,Tag,TrackingPolicy,
+ FactorySpecifier,LockingPolicy,
+ HolderSpecifier
+ > core;
+ typedef typename core::handle_type handle_type;
+ typedef typename core::entry_type entry_type;
+
+public:
+ static const entry_type& entry(const handle_type& h)
+ {
+ return core::factory().entry(h);
+ }
+
+ template<typename Checker>
+ static void erase(const handle_type& h,Checker check)
+ {
+ typedef typename core::lock_type lock_type;
+ lock_type lock(core::mutex());
+ if(check(h))core::factory().erase(h);
+ }
+};
+
+template<
+ typename Value,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
+ >::type entry_type;
+ typedef typename detail::prevent_eti<
+ FactorySpecifier,
+ typename mpl::apply2<
+ FactorySpecifier,
+ entry_type,
+ Value
+ >::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 handle_factory_adaptor<
+ base_factory_type,
+ handle_type,entry_type
+ > factory_type;
+ typedef typename LockingPolicy::mutex_type mutex_type;
+ typedef typename LockingPolicy::lock_type lock_type;
+
+ static handle_type insert(const Value& x)
+ {
+ lock_type lock(mutex());
+ return handle_type(factory().insert(entry_type(x)));
+ }
+
+ static const Value& value(const handle_type& h)
+ {
+ return factory().entry(h);
+ }
+
+ static factory_type& factory()
+ {
+ (void)static_force_holder_get;
+ return holder_type::get().factory;
+ }
+
+ static mutex_type& mutex()
+ {
+ (void)static_force_holder_get;
+ return holder_type::get().mutex;
+ }
+
+private:
+ struct holder_arg
+ {
+ factory_type factory;
+ mutex_type mutex;
+ };
+ typedef typename detail::prevent_eti<
+ HolderSpecifier,
+ typename mpl::apply1<
+ HolderSpecifier,
+ holder_arg
+ >::type
+ >::type holder_type;
+
+ static bool static_force_holder_get;
+};
+
+template<
+ typename Value,typename Tag,typename TrackingPolicy,
+ typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
+>
+bool flyweight_core<
+ Value,Tag,TrackingPolicy,
+ FactorySpecifier,LockingPolicy,HolderSpecifier>::static_force_holder_get=
+ &flyweight_core<
+ Value,Tag,TrackingPolicy,
+ FactorySpecifier,LockingPolicy,HolderSpecifier>::holder_type::get()!=0;
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
+#pragma warning(pop)
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/handle_factory_adaptor.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,48 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_HANDLE_FACTORY_ADAPTOR_HPP
+#define BOOST_FLYWEIGHT_DETAIL_HANDLE_FACTORY_ADAPTOR_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+/* Given a Factory and a Handle type convertible from and implicitly
+ * constructible to Factory::handle_type, handle_factory_adaptor
+ * adapts Factory to present Handle as the associated handle_type.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+template<typename Factory,typename Handle,typename Entry>
+struct handle_factory_adaptor:Factory
+{
+public:
+ typedef Handle handle_type;
+
+ handle_type insert(const Entry& x)
+ {
+ return static_cast<handle_type>(base().insert(x));
+ }
+
+private:
+ Factory& base(){return *this;}
+};
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/msvc60_template_ctors_def.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/msvc60_template_ctors_def.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,68 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_MSVC60_TEMPLATE_CTORS_DEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_MSVC60_TEMPLATE_CTORS_DEF_HPP
+
+#pragma once
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=1
+#define BOOST_FLYWEIGHT_CTORS_1 \
+template<typename T0> explicit flyweight(const T0& t0,int=0):h(core::insert(T(t0))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=2
+#define BOOST_FLYWEIGHT_CTORS_2 \
+template<typename T0,typename T1> explicit flyweight(const T0& t0,const T1& t1):h(core::insert(T(t0,t1))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=3
+#define BOOST_FLYWEIGHT_CTORS_3 \
+template<typename T0,typename T1,typename T2> explicit flyweight(const T0& t0,const T1& t1,const T2& t2):h(core::insert(T(t0,t1,t2))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=4
+#define BOOST_FLYWEIGHT_CTORS_4 \
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=5
+#define BOOST_FLYWEIGHT_CTORS_5 \
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==0
+#define BOOST_FLYWEIGHT_CTORS
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==1
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==2
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==3
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2 \
+BOOST_FLYWEIGHT_CTORS_3
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==4
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2 \
+BOOST_FLYWEIGHT_CTORS_3 \
+BOOST_FLYWEIGHT_CTORS_4
+#else /* BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==5 */
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2 \
+BOOST_FLYWEIGHT_CTORS_3 \
+BOOST_FLYWEIGHT_CTORS_4 \
+BOOST_FLYWEIGHT_CTORS_5
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/msvc60_template_ctors_undef.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/msvc60_template_ctors_undef.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,36 @@
+/* Copyright 2006 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_MSVC60_TEMPLATE_CTORS_UNDEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_MSVC60_TEMPLATE_CTORS_UNDEF_HPP
+
+#pragma once
+
+#undef BOOST_FLYWEIGHT_CTORS
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=1
+#undef BOOST_FLYWEIGHT_CTORS_1
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=2
+#undef BOOST_FLYWEIGHT_CTORS_2
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=3
+#undef BOOST_FLYWEIGHT_CTORS_3
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=4
+#undef BOOST_FLYWEIGHT_CTORS_4
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=5
+#undef BOOST_FLYWEIGHT_CTORS_5
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/not_placeholder_expr.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,58 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
+#define BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+/* BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION can be inserted at the end
+ * of a class template parameter declaration:
+ * template<
+ * typename X0,...,typename Xn
+ * BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION
+ * >
+ * struct foo...
+ * to prevent instantiations from being treated as MPL placeholder
+ * expressions in the presence of placeholder arguments; this is useful
+ * to avoid masking of a metafunction class nested ::apply during
+ * MPL invocation.
+ */
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(__GNUC__, <4)||\
+ BOOST_WORKAROUND(__GNUC__,==4)&&(__GNUC_MINOR__<2)
+/* The default trick on which the macro is based, namely adding a int=0
+ * defaulted template parameter, does not work in GCC prior to 4.2 due to
+ * an unfortunate compiler non-standard extension, as explained in
+ * http://lists.boost.org/boost-users/2007/07/29866.php
+ * We resort to an uglier technique, adding defaulted template parameters
+ * so as to exceed BOOST_MPL_LIMIT_METAFUNCTION_ARITY.
+ */
+
+#include <boost/mpl/limits/arity.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
+
+#define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION \
+BOOST_PP_ENUM_TRAILING_PARAMS( \
+ BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename=int BOOST_PP_INTERCEPT)
+#define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF \
+BOOST_PP_ENUM_TRAILING_PARAMS( \
+ BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT)
+
+#else
+#define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION ,int=0
+#define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF ,int
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/pp_template_ctors_def.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/pp_template_ctors_def.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,127 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_PP_TEMPLATE_CTORS_DEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_PP_TEMPLATE_CTORS_DEF_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=1
+#define BOOST_FLYWEIGHT_CTORS_1 \
+template<typename T0> explicit flyweight(T0& t0):h(core::insert(T(t0))){}\
+template<typename T0> explicit flyweight(const T0& t0):h(core::insert(T(t0))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=2
+#define BOOST_FLYWEIGHT_CTORS_2 \
+template<typename T0,typename T1> explicit flyweight(T0& t0,T1& t1):h(core::insert(T(t0,t1))){}\
+template<typename T0,typename T1> explicit flyweight(T0& t0,const T1& t1):h(core::insert(T(t0,t1))){}\
+template<typename T0,typename T1> explicit flyweight(const T0& t0,T1& t1):h(core::insert(T(t0,t1))){}\
+template<typename T0,typename T1> explicit flyweight(const T0& t0,const T1& t1):h(core::insert(T(t0,t1))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=3
+#define BOOST_FLYWEIGHT_CTORS_3 \
+template<typename T0,typename T1,typename T2> explicit flyweight(T0& t0,T1& t1,T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(T0& t0,T1& t1,const T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(T0& t0,const T1& t1,T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(T0& t0,const T1& t1,const T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(const T0& t0,T1& t1,T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(const T0& t0,T1& t1,const T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(const T0& t0,const T1& t1,T2& t2):h(core::insert(T(t0,t1,t2))){}\
+template<typename T0,typename T1,typename T2> explicit flyweight(const T0& t0,const T1& t1,const T2& t2):h(core::insert(T(t0,t1,t2))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=4
+#define BOOST_FLYWEIGHT_CTORS_4 \
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,T1& t1,T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,T1& t1,T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,T1& t1,const T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,T1& t1,const T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,const T1& t1,T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,const T1& t1,T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,const T1& t1,const T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(T0& t0,const T1& t1,const T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,T1& t1,T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,T1& t1,T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,T1& t1,const T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,T1& t1,const T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,const T1& t1,T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,const T1& t1,T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,T3& t3):h(core::insert(T(t0,t1,t2,t3))){}\
+template<typename T0,typename T1,typename T2,typename T3> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,const T3& t3):h(core::insert(T(t0,t1,t2,t3))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=5
+#define BOOST_FLYWEIGHT_CTORS_5 \
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,const T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,const T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,const T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,T1& t1,const T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,const T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,const T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,const T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,const T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,const T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,const T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,T1& t1,const T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,const T3& t3,T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}\
+template<typename T0,typename T1,typename T2,typename T3,typename T4> explicit flyweight(const T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4):h(core::insert(T(t0,t1,t2,t3,t4))){}
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==0
+#define BOOST_FLYWEIGHT_CTORS
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==1
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==2
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==3
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2 \
+BOOST_FLYWEIGHT_CTORS_3
+#elif BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==4
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2 \
+BOOST_FLYWEIGHT_CTORS_3 \
+BOOST_FLYWEIGHT_CTORS_4
+#else /* BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS==5 */
+#define BOOST_FLYWEIGHT_CTORS \
+BOOST_FLYWEIGHT_CTORS_1 \
+BOOST_FLYWEIGHT_CTORS_2 \
+BOOST_FLYWEIGHT_CTORS_3 \
+BOOST_FLYWEIGHT_CTORS_4 \
+BOOST_FLYWEIGHT_CTORS_5
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/pp_template_ctors_undef.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/pp_template_ctors_undef.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,38 @@
+/* Copyright 2006 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_PP_TEMPLATE_CTORS_UNDEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_PP_TEMPLATE_CTORS_UNDEF_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#undef BOOST_FLYWEIGHT_CTORS
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=1
+#undef BOOST_FLYWEIGHT_CTORS_1
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=2
+#undef BOOST_FLYWEIGHT_CTORS_2
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=3
+#undef BOOST_FLYWEIGHT_CTORS_3
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=4
+#undef BOOST_FLYWEIGHT_CTORS_4
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS>=5
+#undef BOOST_FLYWEIGHT_CTORS_5
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/prevent_eti.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/prevent_eti.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,60 @@
+/* Copyright 2006 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_PREVENT_ETI_HPP
+#define BOOST_FLYWEIGHT_DETAIL_PREVENT_ETI_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/aux_/msvc_never_true.hpp>
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+/* See
+ * http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_MPL
+ * Item 5.6, Beware of the 'early template instantiation' trap.
+ */
+
+template<typename Type,typename Construct>
+struct prevent_eti
+{
+ typedef typename mpl::if_<
+ mpl::aux::msvc_never_true<Type>,
+ mpl::integral_c<int,0>,
+ Construct
+ >::type type;
+};
+#else
+template<typename Type,typename Construct>
+struct prevent_eti
+{
+ typedef Construct type;
+};
+#endif
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/process_id.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/process_id.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,73 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_PROCESS_ID_HPP
+#define BOOST_FLYWEIGHT_DETAIL_PROCESS_ID_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#if defined(BOOST_WINDOWS)&&!defined(BOOST_DISABLE_WIN32)
+
+#if defined(BOOST_USE_WINDOWS_H)
+#include <windows.h>
+#else
+extern "C" __declspec(dllimport)
+unsigned long __stdcall GetCurrentProcessId(void);
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+typedef unsigned long process_id_t;
+
+inline process_id_t process_id()
+{
+ return ::GetCurrentProcessId();
+}
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#elif defined(BOOST_HAS_UNISTD_H)
+
+#include <unistd.h>
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+typedef pid_t process_id_t;
+
+inline process_id_t process_id()
+{
+ return ::getpid();
+}
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#else
+#error Unknown platform
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/recursive_lw_mutex.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,91 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_RECURSIVE_LW_MUTEX_HPP
+#define BOOST_FLYWEIGHT_DETAIL_RECURSIVE_LW_MUTEX_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+/* Recursive lightweight mutex. Relies entirely on
+ * boost::detail::lightweight_mutex, except in Pthreads, where we
+ * explicitly use the PTHREAD_MUTEX_RECURSIVE attribute
+ * (lightweight_mutex uses the default mutex type instead).
+ */
+
+#include <boost/config.hpp>
+
+#if !defined(BOOST_HAS_PTHREADS)
+#include <boost/detail/lightweight_mutex.hpp>
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+typedef boost::detail::lightweight_mutex recursive_lightweight_mutex;
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+#else
+/* code shamelessly ripped from <boost/detail/lwm_pthreads.hpp> */
+
+#include <boost/noncopyable.hpp>
+#include <pthread.h>
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+struct recursive_lightweight_mutex:noncopyable
+{
+ recursive_lightweight_mutex()
+ {
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&m_,&attr);
+ pthread_mutexattr_destroy(&attr);
+ }
+
+ ~recursive_lightweight_mutex(){pthread_mutex_destroy(&m_);}
+
+ struct scoped_lock;
+ friend struct scoped_lock;
+ struct scoped_lock:noncopyable
+ {
+ public:
+ scoped_lock(recursive_lightweight_mutex& m):m_(m.m_)
+ {
+ pthread_mutex_lock(&m_);
+ }
+
+ ~scoped_lock(){pthread_mutex_unlock(&m_);}
+
+ private:
+ pthread_mutex_t& m_;
+ };
+
+private:
+ pthread_mutex_t m_;
+};
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/serialization_helper.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,96 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_SERIALIZATION_HELPER_HPP
+#define BOOST_FLYWEIGHT_DETAIL_SERIALIZATION_HELPER_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#include <boost/multi_index/random_access_index.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/serialization/extended_type_info.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+/* TODO:comment
+ */
+
+template<typename Flyweight>
+struct flyweight_value_address
+{
+ typedef const typename Flyweight::value_type* result_type;
+
+ result_type operator()(const Flyweight& x)const{return &x.get();}
+};
+
+template<typename Flyweight>
+class serialization_helper:private noncopyable
+{
+ typedef multi_index::multi_index_container<
+ Flyweight,
+ multi_index::indexed_by<
+ multi_index::random_access<>,
+ multi_index::hashed_unique<flyweight_value_address<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];}
+
+ 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;}
+
+private:
+ table t;
+};
+
+template<typename Flyweight,class Archive>
+serialization_helper<Flyweight>& get_serialization_helper(
+ Archive & ar
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ typedef serialization_helper<Flyweight> helper;
+
+ serialization::extended_type_info* eti=
+ 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);
+ ar.insert_helper(eti, sph);
+ }
+ return *static_cast<helper*>(sph.get());
+}
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/template_ctors_def.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/template_ctors_def.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,39 @@
+/* Copyright 2006 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_TEMPLATE_CTORS_DEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_TEMPLATE_CTORS_DEF_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+
+/* This user_definable macro limits the maximum number of arguments of
+ * flyweight template ctors. Beware combinatorial explosion: in order to
+ * implement perfect forwarding there are 2^n distinct ctors accepting
+ * n args.
+ */
+
+#if !defined(BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS)
+#define BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS 5
+#endif
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS<=5
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+#include <boost/flyweight/detail/msvc60_template_ctors_def.hpp>
+#else
+#include <boost/flyweight/detail/pp_template_ctors_def.hpp>
+#endif
+#else
+#include <boost/flyweight/detail/dyn_template_ctors_def.hpp>
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/detail/template_ctors_undef.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/detail/template_ctors_undef.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,29 @@
+/* Copyright 2006 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_TEMPLATE_CTORS_UNDEF_HPP
+#define BOOST_FLYWEIGHT_DETAIL_TEMPLATE_CTORS_UNDEF_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS<=5
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+#include <boost/flyweight/detail/msvc60_template_ctors_undef.hpp>
+#else
+#include <boost/flyweight/detail/pp_template_ctors_undef.hpp>
+#endif
+#else
+#include <boost/flyweight/detail/dyn_template_ctors_undef.hpp>
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/factory_tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/factory_tag.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,44 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_FACTORY_TAG_HPP
+#define BOOST_FLYWEIGHT_FACTORY_TAG_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/parameter/parameters.hpp>
+#include <boost/type_traits/is_base_and_derived.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+/* Three ways to indicate that a given class T is a factory specifier:
+ * 1. Make it derived from factory_marker.
+ * 2. Specialize is_factory to evaluate to boost::mpl::true_.
+ * 3. Pass it as factory<T> when defining a flyweight type.
+ */
+
+struct factory_marker{};
+
+template<typename T>
+struct is_factory:is_base_and_derived<factory_marker,T>
+{};
+
+template<typename T=parameter::void_>
+struct factory:parameter::template_keyword<factory<>,T>
+{};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/flyweight.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/flyweight.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,360 @@
+/* Flyweight class.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_FLYWEIGHT_HPP
+#define BOOST_FLYWEIGHT_FLYWEIGHT_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <algorithm>
+#include <boost/detail/workaround.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>
+#include <boost/flyweight/simple_locking_fwd.hpp>
+#include <boost/flyweight/static_holder_fwd.hpp>
+#include <boost/flyweight/hashed_factory_fwd.hpp>
+#include <boost/flyweight/holder_tag.hpp>
+#include <boost/flyweight/refcounted_fwd.hpp>
+#include <boost/flyweight/tag.hpp>
+#include <boost/flyweight/tracking_tag.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/parameter/binding.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
+#pragma warning(push)
+#pragma warning(disable:4521) /* multiple copy ctors */
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+/* Used for the detection of unmatched template args in a
+ * flyweight instantiation.
+ */
+
+struct unmatched_arg;
+
+} /* namespace flyweights::detail */
+
+template<
+ typename T,
+ typename Arg1,typename Arg2,typename Arg3,typename Arg4,typename Arg5
+>
+class flyweight
+{
+private:
+ typedef parameter::parameters<
+ parameter::optional<
+ parameter::deduced<tag<> >,
+ detail::is_tag<boost::mpl::_>
+ >,
+ parameter::optional<
+ parameter::deduced<tracking<> >,
+ is_tracking<boost::mpl::_>
+ >,
+ parameter::optional<
+ parameter::deduced<factory<> >,
+ is_factory<boost::mpl::_>
+ >,
+ parameter::optional<
+ parameter::deduced<locking<> >,
+ is_locking<boost::mpl::_>
+ >,
+ parameter::optional<
+ parameter::deduced<holder<> >,
+ is_holder<boost::mpl::_>
+ >
+ > signature;
+ typedef typename signature::bind<
+ Arg1,Arg2,Arg3,Arg4,Arg5
+ >::type args;
+ typedef typename parameter::binding<
+ args,tag<>,mpl::na
+ >::type tag_type;
+ typedef typename parameter::binding<
+ args,tracking<>,refcounted
+ >::type tracking_policy;
+ typedef typename parameter::binding<
+ args,factory<>,hashed_factory<>
+ >::type factory_specifier;
+ typedef typename parameter::binding<
+ args,locking<>,simple_locking
+ >::type locking_policy;
+ typedef typename parameter::binding<
+ args,holder<>,static_holder
+ >::type holder_specifier;
+
+ typedef parameter::parameters<
+ parameter::optional<
+ parameter::deduced<
+ detail::unmatched_arg
+ >,
+ mpl::not_<
+ mpl::or_<
+ detail::is_tag<boost::mpl::_>,
+ is_tracking<boost::mpl::_>,
+ is_factory<boost::mpl::_>,
+ is_locking<boost::mpl::_>,
+ is_holder<boost::mpl::_>
+ >
+ >
+ >
+ > unmatched_signature;
+ typedef typename unmatched_signature::bind<
+ Arg1,Arg2,Arg3,Arg4,Arg5
+ >::type unmatched_args;
+ typedef typename parameter::binding<
+ 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));
+
+ typedef detail::flyweight_core<
+ T,tag_type,tracking_policy,
+ factory_specifier,locking_policy,
+ holder_specifier
+ > core;
+ typedef typename core::handle_type handle_type;
+
+public:
+ typedef T value_type;
+
+ /* construct/copy/destroy */
+
+ flyweight():h(core::insert(T())){}
+ 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));}
+
+ /* convertibility to underlying type */
+
+ const T& get()const{return core::value(h);}
+
+ operator const T&()const{return get();}
+
+ /* exact type equality */
+
+ friend bool operator==(const flyweight& x,const flyweight& y)
+ {
+ return &x.get()==&y.get();
+ }
+
+ /* modifiers */
+
+ void swap(flyweight& x){std::swap(h,x.h);}
+
+private:
+ handle_type h;
+};
+
+#define BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(n) \
+typename Arg##n##1,typename Arg##n##2,typename Arg##n##3, \
+typename Arg##n##4,typename Arg##n##5
+#define BOOST_FLYWEIGHT_TEMPL_ARGS(n) \
+Arg##n##1,Arg##n##2,Arg##n##3,Arg##n##4,Arg##n##5
+
+/* Comparison. Unlike exact type comparison defined above, intertype
+ * comparison just forwards to the underlying objects.
+ */
+
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator==(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
+ const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y)
+{
+ return x.get()==y.get();
+}
+
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator<(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
+ const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y)
+{
+ return x.get()<y.get();
+}
+
+#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2
+>
+bool operator==(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y)
+{
+ return x.get()==y;
+}
+
+template<
+ typename T1,
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator==(
+ const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y)
+{
+ return x==y.get();
+}
+
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2
+>
+bool operator<(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y)
+{
+ return x.get()<y;
+}
+
+template<
+ typename T1,
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator<(
+ const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y)
+{
+ return x<y.get();
+}
+#endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
+
+/* rest of comparison operators */
+
+#define BOOST_FLYWEIGHT_COMPLETE_COMP_OPS(t,a1,a2) \
+template<t> \
+inline bool operator!=(const a1& x,const a2& y) \
+{ \
+ return !(x==y); \
+} \
+ \
+template<t> \
+inline bool operator>(const a1& x,const a2& y) \
+{ \
+ return y<x; \
+} \
+ \
+template<t> \
+inline bool operator>=(const a1& x,const a2& y) \
+{ \
+ return !(x<y); \
+} \
+ \
+template<t> \
+inline bool operator<=(const a1& x,const a2& y) \
+{ \
+ return !(y<x); \
+}
+
+BOOST_FLYWEIGHT_COMPLETE_COMP_OPS(
+ typename T1 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
+ typename T2 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
+ flyweight<
+ T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
+ >,
+ flyweight<
+ T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
+ >)
+
+#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
+BOOST_FLYWEIGHT_COMPLETE_COMP_OPS(
+ typename T1 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
+ typename T2,
+ flyweight<
+ T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
+ >,
+ T2)
+
+BOOST_FLYWEIGHT_COMPLETE_COMP_OPS(
+ typename T1 BOOST_PP_COMMA()
+ typename T2 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
+ T1,
+ flyweight<
+ T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
+ >)
+#endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
+
+/* specialized algorithms */
+
+template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
+void swap(
+ flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x,
+ flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& y)
+{
+ x.swap(y);
+}
+
+template<
+ BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
+ BOOST_TEMPLATED_STREAM_COMMA
+ typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
+>
+BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& operator<<(
+ BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& out,
+ const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x)
+{
+ return out<<x.get();
+}
+
+template<
+ BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
+ BOOST_TEMPLATED_STREAM_COMMA
+ typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
+>
+BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& operator>>(
+ 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 */
+ in>>t;
+ x=t;
+ return in;
+}
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#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)
+#endif
+
+#endif

Added: sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/flyweight_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,166 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_FLYWEIGHT_FWD_HPP
+#define BOOST_FLYWEIGHT_FLYWEIGHT_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/templated_streams.hpp>
+#include <boost/parameter/parameters.hpp>
+#include <boost/preprocessor/punctuation/comma.hpp>
+#include <iosfwd>
+
+namespace boost{
+
+namespace flyweights{
+
+template<
+ typename T,
+ typename Arg1=parameter::void_,
+ typename Arg2=parameter::void_,
+ typename Arg3=parameter::void_,
+ typename Arg4=parameter::void_,
+ typename Arg5=parameter::void_
+>
+class flyweight;
+
+#define BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(n) \
+typename Arg##n##1,typename Arg##n##2,typename Arg##n##3, \
+typename Arg##n##4,typename Arg##n##5
+#define BOOST_FLYWEIGHT_TEMPL_ARGS(n) \
+Arg##n##1,Arg##n##2,Arg##n##3,Arg##n##4,Arg##n##5
+
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator==(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
+ const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
+
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator<(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
+ const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
+
+#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2
+>
+bool operator==(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
+
+template<
+ typename T1,
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator==(
+ const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
+
+template<
+ typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
+ typename T2
+>
+bool operator<(
+ const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
+
+template<
+ typename T1,
+ typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
+>
+bool operator<(
+ const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
+#endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
+
+#define BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(t,a1,a2) \
+template<t> \
+inline bool operator!=(const a1& x,const a2& y); \
+ \
+template<t> \
+inline bool operator>(const a1& x,const a2& y); \
+ \
+template<t> \
+inline bool operator>=(const a1& x,const a2& y); \
+ \
+template<t> \
+inline bool operator<=(const a1& x,const a2& y); \
+
+BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
+ typename T1 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
+ typename T2 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
+ flyweight<
+ T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
+ >,
+ flyweight<
+ T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
+ >)
+
+#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
+BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
+ typename T1 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
+ typename T2,
+ flyweight<
+ T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
+ >,
+ T2)
+
+BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
+ typename T1 BOOST_PP_COMMA()
+ typename T2 BOOST_PP_COMMA()
+ BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
+ T1,
+ flyweight<
+ T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
+ >)
+#endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
+
+template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
+inline void swap(
+ flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x,
+ flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& y);
+
+template<
+ BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
+ BOOST_TEMPLATED_STREAM_COMMA
+ typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
+>
+inline BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& operator<<(
+ BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& out,
+ const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
+
+template<
+ BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
+ BOOST_TEMPLATED_STREAM_COMMA
+ typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
+>
+inline BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& operator>>(
+ BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& in,
+ flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
+
+} /* namespace flyweights */
+
+using flyweights::flyweight;
+
+} /* namespace boost */
+
+#undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL
+#undef BOOST_FLYWEIGHT_TEMPL_ARGS
+#undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS
+
+#endif

Added: sandbox/flyweight/boost/flyweight/hashed_factory.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/hashed_factory.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,133 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_HASHED_FACTORY_HPP
+#define BOOST_FLYWEIGHT_HASHED_FACTORY_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/factory_tag.hpp>
+#include <boost/flyweight/hashed_factory_fwd.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/identity.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/if.hpp>
+
+/* Flyweight factory based on a hashed container implemented
+ * with Boost.MultiIndex.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+template<
+ typename Entry,typename Value,
+ typename Hash,typename Pred,typename Allocator
+>
+class hashed_factory_class:public factory_marker
+{
+ struct index_list:
+ boost::mpl::vector1<
+ multi_index::hashed_unique<
+ multi_index::identity<Entry>,
+ typename boost::mpl::if_<
+ mpl::is_na<Hash>,
+ hash<Value>,
+ Hash
+ >::type,
+ typename boost::mpl::if_<
+ mpl::is_na<Pred>,
+ std::equal_to<Value>,
+ Pred
+ >::type
+ >
+ >
+ {};
+
+ typedef multi_index::multi_index_container<
+ Entry,
+ index_list,
+ typename boost::mpl::if_<
+ mpl::is_na<Allocator>,
+ std::allocator<Entry>,
+ Allocator
+ >::type
+ > container_type;
+
+public:
+ typedef const Entry* handle_type;
+
+ handle_type insert(const Entry& x)
+ {
+ return &*cont.insert(x).first;
+ }
+
+ void erase(handle_type h)
+ {
+ cont.erase(cont.iterator_to(*h));
+ }
+
+ const Entry& entry(handle_type h){return *h;}
+
+private:
+ container_type cont;
+
+public:
+ typedef hashed_factory_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 5,hashed_factory_class,(Entry,Value,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>
+ struct apply:
+ mpl::apply2<
+ detail::hashed_factory_class_fwd<
+ boost::mpl::_1,boost::mpl::_2,Hash,Pred,Allocator
+ >,
+ Entry,Value
+ >
+ {};
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/hashed_factory_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,40 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_HASHED_FACTORY_FWD_HPP
+#define BOOST_FLYWEIGHT_HASHED_FACTORY_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/detail/not_placeholder_expr.hpp>
+#include <boost/mpl/aux_/na.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+template<
+ typename Entry,typename Value,
+ typename Hash=mpl::na,typename Pred=mpl::na,typename Allocator=mpl::na
+>
+class hashed_factory_class;
+
+template<
+ typename Hash=mpl::na,typename Pred=mpl::na,typename Allocator=mpl::na
+ BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION
+>
+struct hashed_factory;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/holder_tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/holder_tag.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,44 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_HOLDER_TAG_HPP
+#define BOOST_FLYWEIGHT_HOLDER_TAG_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/parameter/parameters.hpp>
+#include <boost/type_traits/is_base_and_derived.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+/* Three ways to indicate that a given class T is a holder specifier:
+ * 1. Make it derived from holder_marker.
+ * 2. Specialize is_holder to evaluate to boost::mpl::true_.
+ * 3. Pass it as holder<T> when defining a flyweight type.
+ */
+
+struct holder_marker{};
+
+template<typename T>
+struct is_holder:is_base_and_derived<holder_marker,T>
+{};
+
+template<typename T=parameter::void_>
+struct holder:parameter::template_keyword<holder<>,T>
+{};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/intermodule_holder.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/intermodule_holder.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,192 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_INTERMODULE_HOLDER_HPP
+#define BOOST_FLYWEIGHT_INTERMODULE_HOLDER_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/holder_tag.hpp>
+#include <boost/flyweight/intermodule_holder_fwd.hpp>
+#include <boost/flyweight/detail/process_id.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/interprocess/sync/named_mutex.hpp>
+#include <boost/interprocess/sync/scoped_lock.hpp>
+#include <boost/interprocess/managed_shared_memory.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <cstdio>
+#include <cstring>
+#include <memory>
+
+/* intermodule_holder_class guarantees a unique instance across all dynamic
+ * modules of a program.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+template<typename C>
+struct intermodule_holder_class
+{
+ static C& get()
+ {
+ static instantiator instance;
+ return instance.get();
+ }
+
+private:
+ struct instantiator
+ {
+ instantiator():
+ mutex(interprocess::open_or_create,compute_mutex_name()),
+ seg(interprocess::open_or_create,compute_segment_name(),16384),
+ ppref(0),
+ pc(0)
+ {
+ /* Instance creation is done according to a two-phase protocol so
+ * that we call "new" in an unlocked situation, thus minimizing the
+ * chance of leaving dangling locks due to catastrophic failure.
+ */
+
+ {
+ interprocess::scoped_lock<interprocess::named_mutex> lock(mutex);
+ ppref=seg.find_or_construct<referenced_instance*>(
+ typeid(C).name())((referenced_instance*)0);
+ if(*ppref){
+ /* As in some OSes Boost.Interprocess memory segments can outlive
+ * their associated processes, there is a possibility that we
+ * retrieve a dangling pointer (coming from a previous aborted run,
+ * for instance). Try to protect against this by checking that
+ * the contents of the pointed object are consistent.
+ */
+ if(std::strcmp(segment_name,(*ppref)->segment_name)!=0){
+ *ppref=0; /* dangling pointer! */
+ }
+ else ++((*ppref)->ref);
+ }
+ }
+ if(!*ppref){
+ std::auto_ptr<referenced_instance> apc(
+ new referenced_instance(segment_name));
+ interprocess::scoped_lock<interprocess::named_mutex> lock(mutex);
+ ppref=seg.find_or_construct<referenced_instance*>(
+ typeid(C).name())((referenced_instance*)0);
+ if(!*ppref)*ppref=apc.release();
+ ++((*ppref)->ref);
+ }
+ pc=&(*ppref)->c;
+ }
+
+ ~instantiator()
+ {
+ /* As in construction time, actual deletion is performed outside the
+ * lock to avoid leaving the lock dangling in case of crash.
+ */
+
+ referenced_instance* pref=0;
+ {
+ interprocess::scoped_lock<interprocess::named_mutex> lock(mutex);
+ if(--((*ppref)->ref)==0){
+ pref=*ppref;
+ *ppref=0;
+ }
+ }
+ if(pref)delete pref;
+ }
+
+ C& get()const{return *pc;}
+
+ private:
+ /* Although mutex and seg are system-wide, their names intend to
+ * make them specific for the current process and type, hence their
+ * containing process id and type id info.
+ */
+
+ char mutex_name[128];
+ char segment_name[128];
+
+ const char* compute_mutex_name()
+ {
+ std::sprintf(
+ mutex_name,
+ "boost_flyweight_intermodule_holder_mutex_"
+ "%ld_%u_%u_%u_%u",
+ (long)detail::process_id(),
+ (unsigned)compute_hash(typeid(C).name(),0),
+ (unsigned)compute_hash(typeid(C).name(),1),
+ (unsigned)compute_hash(typeid(C).name(),2),
+ (unsigned)compute_hash(typeid(C).name(),3));
+
+ return mutex_name;
+ }
+
+ const char* compute_segment_name()
+ {
+ std::sprintf(
+ segment_name,
+ "boost_flyweight_intermodule_holder_segment_"
+ "%ld_%u_%u_%u_%u",
+ (long)detail::process_id(),
+ (unsigned)compute_hash(typeid(C).name(),0),
+ (unsigned)compute_hash(typeid(C).name(),1),
+ (unsigned)compute_hash(typeid(C).name(),2),
+ (unsigned)compute_hash(typeid(C).name(),3));
+
+ return segment_name;
+ }
+
+ static std::size_t compute_hash(const char* str,std::size_t off)
+ {
+ std::size_t len=std::strlen(str);
+ if(off>len)off=len;
+ return hash_range(str+off,str+len);
+ }
+
+ interprocess::named_mutex mutex;
+ interprocess::managed_shared_memory seg;
+ struct referenced_instance
+ {
+ referenced_instance(const char* segment_name_):ref(0)
+ {
+ strcpy(segment_name,segment_name_);
+ }
+
+ ~referenced_instance(){segment_name[0]='\0';}
+
+ char segment_name[128]; /* used to detect dangling pointers */
+ mutable long ref;
+ C c;
+ }** ppref;
+ C* pc;
+ };
+
+public:
+ typedef intermodule_holder_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,intermodule_holder_class,(C))
+};
+
+/* intermodule_holder_class specifier */
+
+struct intermodule_holder:holder_marker
+{
+ template<typename C>
+ struct apply
+ {
+ typedef intermodule_holder_class<C> type;
+ };
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/intermodule_holder_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,29 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_INTERMODULE_HOLDER_FWD_HPP
+#define BOOST_FLYWEIGHT_INTERMODULE_HOLDER_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+template<typename C>
+struct intermodule_holder_class;
+
+struct intermodule_holder;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/locking_tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/locking_tag.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,44 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_LOCKING_TAG_HPP
+#define BOOST_FLYWEIGHT_LOCKING_TAG_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/parameter/parameters.hpp>
+#include <boost/type_traits/is_base_and_derived.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+/* Three ways to indicate that a given class T is a locking policy:
+ * 1. Make it derived from locking_marker.
+ * 2. Specialize is_locking to evaluate to boost::mpl::true_.
+ * 3. Pass it as locking<T> when defining a flyweight type.
+ */
+
+struct locking_marker{};
+
+template<typename T>
+struct is_locking:is_base_and_derived<locking_marker,T>
+{};
+
+template<typename T=parameter::void_>
+struct locking:parameter::template_keyword<locking<>,T>
+{};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/no_locking.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/no_locking.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,36 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_NO_LOCKING_HPP
+#define BOOST_FLYWEIGHT_NO_LOCKING_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/no_locking_fwd.hpp>
+#include <boost/flyweight/locking_tag.hpp>
+
+/* null locking policy */
+
+namespace boost{
+
+namespace flyweights{
+
+struct no_locking:locking_marker
+{
+ struct mutex_type{};
+ typedef mutex_type lock_type;
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/no_locking_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,26 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_NO_LOCKING_FWD_HPP
+#define BOOST_FLYWEIGHT_NO_LOCKING_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+struct no_locking;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/no_tracking.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/no_tracking.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,46 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_NO_TRACKING_HPP
+#define BOOST_FLYWEIGHT_NO_TRACKING_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/no_tracking_fwd.hpp>
+#include <boost/flyweight/tracking_tag.hpp>
+
+/* Null tracking policy: elements are never erased from the factory.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+struct no_tracking:tracking_marker
+{
+ struct entry_type
+ {
+ template<typename Value>
+ struct apply{typedef Value type;};
+ };
+
+ struct handle_type
+ {
+ template<typename Handle,typename TrackingHelper>
+ struct apply{typedef Handle type;};
+ };
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/no_tracking_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,26 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_NO_TRACKING_FWD_HPP
+#define BOOST_FLYWEIGHT_NO_TRACKING_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+struct no_tracking;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/refcounted.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/refcounted.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,134 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_REFCOUNTED_HPP
+#define BOOST_FLYWEIGHT_REFCOUNTED_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <algorithm>
+#include <boost/detail/atomic_count.hpp>
+#include <boost/detail/workaround.hpp>
+#include <boost/flyweight/refcounted_fwd.hpp>
+#include <boost/flyweight/tracking_tag.hpp>
+
+/* Refcounting tracking policy: values have an embedded ref count,
+ * when this goes down to zero the element is erased from the
+ * factory.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+template<typename Value>
+class refcounted_value
+{
+public:
+ explicit refcounted_value(const Value& x_):
+ x(x_),ref(0)
+ {}
+
+ refcounted_value(const refcounted_value& r):
+ x(r.x),ref(0)
+ {}
+
+ refcounted_value& operator=(const refcounted_value& r)
+ {
+ x=r.x;
+ return *this;
+ }
+
+ operator const Value&()const{return x;}
+
+#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
+private:
+ template<typename,typename> friend class refcounted_handle;
+#endif
+
+ long count()const{return ref;}
+ void add_ref()const{++ref;}
+ bool release()const{return (--ref==0);}
+
+private:
+ Value x;
+ mutable boost::detail::atomic_count ref;
+};
+
+template<typename Handle,typename TrackingHelper>
+class refcounted_handle
+{
+public:
+ explicit refcounted_handle(const Handle& h_):h(h_)
+ {
+ TrackingHelper::entry(*this).add_ref();
+ }
+
+ refcounted_handle(const refcounted_handle& x):h(x.h)
+ {
+ TrackingHelper::entry(*this).add_ref();
+ }
+
+ refcounted_handle& operator=(const refcounted_handle& x)
+ {
+ refcounted_handle tmp(x);
+ std::swap(h,tmp.h);
+ return *this;
+ }
+
+ ~refcounted_handle()
+ {
+ if(TrackingHelper::entry(*this).release()){
+ TrackingHelper::erase(*this,check_erase);
+ }
+ }
+
+ operator const Handle&()const{return h;}
+
+private:
+ static bool check_erase(const refcounted_handle& x)
+ {
+ return TrackingHelper::entry(x).count()==0;
+ }
+
+ Handle h;
+};
+
+} /* namespace flyweights::detail */
+
+struct refcounted:tracking_marker
+{
+ struct entry_type
+ {
+ template<typename Value>
+ struct apply
+ {
+ typedef detail::refcounted_value<Value> type;
+ };
+ };
+
+ struct handle_type
+ {
+ template<typename Handle,typename TrackingHelper>
+ struct apply
+ {
+ typedef detail::refcounted_handle<Handle,TrackingHelper> type;
+ };
+ };
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/refcounted_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,26 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_REFCOUNTED_FWD_HPP
+#define BOOST_FLYWEIGHT_REFCOUNTED_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+struct refcounted;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/serialize.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/serialize.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,101 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_FLYWEIGHT_SERIALIZE_HPP
+#define BOOST_FLYWEIGHT_FLYWEIGHT_SERIALIZE_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight_fwd.hpp>
+#include <boost/flyweight/detail/archive_constructed.hpp>
+#include <boost/flyweight/detail/serialization_helper.hpp>
+#include <boost/serialization/nvp.hpp>
+#include <boost/serialization/split_free.hpp>
+#include <boost/throw_exception.hpp>
+#include <memory>
+
+/* Serialization routines for flyweight<T>.
+ * TODO: comment
+ */
+
+namespace boost{
+
+namespace serialization{
+
+template<
+ class Archive,
+ typename T,typename Arg1,typename Arg2,typename Arg3
+>
+inline void serialize(
+ Archive& ar,::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f,
+ const unsigned int version)
+{
+ split_free(ar,f,version);
+}
+
+template<
+ class Archive,
+ typename T,typename Arg1,typename Arg2,typename Arg3
+>
+void save(
+ 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;
+
+ helper& hlp=
+ ::boost::flyweights::detail::get_serialization_helper<flyweight>(ar);
+
+ size_type n=hlp.find(f);
+ ar<<make_nvp("item",n);
+ if(n==hlp.size()){
+ ar<<make_nvp("value",f.get());
+ hlp.push_back(f);
+ }
+}
+
+template<
+ class Archive,
+ typename T,typename Arg1,typename Arg2,typename Arg3
+>
+void load(
+ 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;
+
+ helper& hlp=
+ ::boost::flyweights::detail::get_serialization_helper<flyweight>(ar);
+
+ size_type n=0;
+ ar>>make_nvp("item",n);
+ if(n>hlp.size()){
+ throw_exception(
+ archive::archive_exception(archive::archive_exception::other_exception));
+ }
+ else if(n==hlp.size()){
+ ::boost::flyweights::detail::archive_constructed<T> v("value",ar,version);
+ hlp.push_back(flyweight(v.get()));
+ }
+ f=hlp[n];
+}
+
+} /* namespace serialization */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/set_factory.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/set_factory.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,99 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_SET_FACTORY_HPP
+#define BOOST_FLYWEIGHT_SET_FACTORY_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/allocator_utilities.hpp>
+#include <boost/flyweight/assoc_container_factory.hpp>
+#include <boost/flyweight/factory_tag.hpp>
+#include <boost/flyweight/set_factory_fwd.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/if.hpp>
+#include <set>
+
+/* Particularization of assoc_container_factory_class using a set.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+template<
+ typename Entry,typename Value,
+ typename Compare,typename Allocator
+>
+class set_factory_class:
+ public assoc_container_factory_class<
+ std::set<
+ Entry,
+ typename boost::mpl::if_<
+ mpl::is_na<Compare>,
+ std::less<Value>,
+ Compare
+ >::type,
+ typename boost::mpl::if_<
+ mpl::is_na<Allocator>,
+ std::allocator<Entry>,
+ Allocator
+ >::type
+ >
+ >
+{
+public:
+ typedef set_factory_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(
+ 4,set_factory_class,(Entry,Value,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>
+ struct apply:
+ mpl::apply2<
+ detail::set_factory_class_fwd<
+ boost::mpl::_1,boost::mpl::_2,Compare,Allocator
+ >,
+ Entry,Value
+ >
+ {};
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/set_factory_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,40 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_SET_FACTORY_FWD_HPP
+#define BOOST_FLYWEIGHT_SET_FACTORY_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/detail/not_placeholder_expr.hpp>
+#include <boost/mpl/aux_/na.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+template<
+ typename Entry,typename Value,
+ typename Compare=mpl::na,typename Allocator=mpl::na
+>
+class set_factory_class;
+
+template<
+ typename Compare=mpl::na,typename Allocator=mpl::na
+ BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION
+>
+struct set_factory;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/simple_locking.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/simple_locking.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,37 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_SIMPLE_LOCKING_HPP
+#define BOOST_FLYWEIGHT_SIMPLE_LOCKING_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/detail/recursive_lw_mutex.hpp>
+#include <boost/flyweight/simple_locking_fwd.hpp>
+#include <boost/flyweight/locking_tag.hpp>
+
+/* simple locking policy based on native recursive mutexes */
+
+namespace boost{
+
+namespace flyweights{
+
+struct simple_locking:locking_marker
+{
+ typedef detail::recursive_lightweight_mutex mutex_type;
+ typedef mutex_type::scoped_lock lock_type;
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/simple_locking_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,26 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_SIMPLE_LOCKING_FWD_HPP
+#define BOOST_FLYWEIGHT_SIMPLE_LOCKING_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+struct simple_locking;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/static_holder.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/static_holder.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,56 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_STATIC_HOLDER_HPP
+#define BOOST_FLYWEIGHT_STATIC_HOLDER_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/static_holder_fwd.hpp>
+#include <boost/flyweight/holder_tag.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+
+/* Simplest holder storing the T object as a local static variable.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+template<typename C>
+struct static_holder_class:holder_marker
+{
+ static C& get()
+ {
+ static C c;
+ return c;
+ }
+
+ typedef static_holder_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,static_holder_class,(C))
+};
+
+/* static_holder_class specifier */
+
+struct static_holder:holder_marker
+{
+ template<typename C>
+ struct apply
+ {
+ typedef static_holder_class<C> type;
+ };
+};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/static_holder_fwd.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,29 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_STATIC_HOLDER_FWD_HPP
+#define BOOST_FLYWEIGHT_STATIC_HOLDER_FWD_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+namespace boost{
+
+namespace flyweights{
+
+template<typename C>
+struct static_holder_class;
+
+struct static_holder;
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/tag.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,46 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TAG_HPP
+#define BOOST_FLYWEIGHT_TAG_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/parameter/parameters.hpp>
+#include <boost/type_traits/is_base_and_derived.hpp>
+
+/* A type T can be used as a tag in the specification of a flyweight
+ * by passing it wrapped in the form tag<T>.
+ */
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+struct tag_marker{};
+
+template<typename T>
+struct is_tag:is_base_and_derived<tag_marker,T>
+{};
+
+} /* namespace flyweights::detail */
+
+template<typename T=parameter::void_>
+struct tag:parameter::template_keyword<tag<>,T>,detail::tag_marker
+{};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/boost/flyweight/tracking_tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/boost/flyweight/tracking_tag.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,44 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TRACKING_TAG_HPP
+#define BOOST_FLYWEIGHT_TRACKING_TAG_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/parameter/parameters.hpp>
+#include <boost/type_traits/is_base_and_derived.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+/* Three ways to indicate that a given class T is a tracking policy:
+ * 1. Make it derived from tracking_marker.
+ * 2. Specialize is_tracking to evaluate to boost::mpl::true_.
+ * 3. Pass it as tracking<T> when defining a flyweight type.
+ */
+
+struct tracking_marker{};
+
+template<typename T>
+struct is_tracking:is_base_and_derived<tracking_marker,T>
+{};
+
+template<typename T=parameter::void_>
+struct tracking:parameter::template_keyword<tracking<>,T>
+{};
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif

Added: sandbox/flyweight/libs/flyweight/doc/acknowledgements.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/acknowledgements.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<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="xxx.html">
+<link rel="up" href="index.html">
+</head>
+
+<body>
+<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight Acknowledgements</h1>
+
+<div class="prev_link"><a href="xxx.html"><img src="prev.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[not linked yet]</font>
+</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">
+</div><br clear="all" style="clear: all;">
+
+<hr>
+
+<h3 align="center">Disclaimer: Boost.Flyweight is not a Boost library</h3>
+
+<p>
+The following people has provided valuable feedback and suggestions during the
+development of the library: Janek Kozicki, Tobias Schwinger,
+Pavel Vo&#382;en&iacute;lek. Rosa Bern&aacute;rdez has proofread the
+documentation from the first drafts up to its present form.
+</p>
+
+<p>
+Boost.Flyweight relies on the
+Boost MPL Library from
+Aleksey Gurtovoy. The
+<a href="tutorial/configuration.html#free_order_template">free-order template
+parameter interface</a> offered by the library has been implemented
+with the <a href="../../parameter/doc/html/index.html">Boost Parameter
+Library</a> from David Abrahams and Daniel Wallin. Ion Gazta&ntilde;aga's
+Boost Interprocess Library
+is the core element behind the
+intermodule_holder
+component. Boost.Flyweight serialization capabilities are based on the
+Boost Serialization Library
+from Robert Ramey.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="xxx.html"><img src="prev.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[not linked yet]</font>
+</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">
+</div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised August 16th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/examples.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/examples.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,210 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<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="xxx.html">
+<link rel="up" href="index.html">
+<link rel="next" href="xxx.html">
+</head>
+
+<body>
+<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight Examples</h1>
+
+<div class="prev_link"><a href="xxx.html"><img src="prev.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[not linked yet]</font>
+</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="xxx.html"><img src="next.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[not linked yet]</font>
+</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>
+</ul>
+
+<h2><a name="example1">Example 1: basic usage</a></h2>
+
+<p>
+See source code.
+</p>
+
+<p>
+Dummy program showing the basic capabilities of <code>flyweight</code>
+explained at the tutorial.
+</p>
+
+<h2><a name="example2">Example 2: flyweights and the composite pattern</a></h2>
+
+<p>
+See source code.
+</p>
+
+<p>
+The <a href="http://c2.com/cgi/wiki?CompositePattern"><i>composite
+design pattern</i></a> revolves about the idea that a tree data structure
+can be easily constructed and manipulated by defining the tree node type
+polymorphically so that either is leaf node or else contains a list of
+pointers to their child nodes.
+This way, a tree is the exact same entity as its root node, which allows
+for very simple recursive tree-handling algorithms. Large composite trees
+having a high degree of duplication of nodes and subtrees (as for instance
+those generated when parsing a computer program) are a natural fit for the
+flyweight idiom: simply turning the node type into a flyweight
+automatically deals with duplication at the node and subtree level.
+</p>
+
+<p>
+The example program parses Lisp-like lists of the form
+<code>(a<sub>1</sub> ... a<sub><i>n</i></sub>)</code> where each
+<code>a<sub>i</sub></code> is a terminal string or a list. The parsed
+data structure is a composite type defined using Boost.Flyweight in conjunction
+with the recursive facilities of
+Boost.Variant. So, given the list
+</p>
+
+<blockquote><pre>
+(= (tan (+ x y))(/ (+ (tan x)(tan y))(- 1 (* (tan x)(tan y)))))
+</pre></blockquote>
+
+<p>
+the resulting data structure implicitly detects the duplicated
+occurrences of <code>+</code>, <code>x</code>, <code>y</code>,
+<code>tan</code>, <code>(tan x)</code> and <code>(tan y)</code>.
+</p>
+
+<h2><a name="example3">Example 3: formatted text processing</a></h2>
+
+<p>
+See source code.
+</p>
+
+<p>
+A classic example of application of the flyweight pattern is that of a
+text processor which handles characters with rich formatting information,
+like font type, size, color and special options (boldness, italics, etc.)
+Coding the formatting information of each character takes considerable
+space, but, given the high degree of repetition typical in a document,
+maintaining formatted characters as flyweight objects drastically reduces
+memory consumption.
+</p>
+
+<p>
+The example program parses, manipulates and stores HTML documents following
+flyweight-based representation techniques. Given the hierarchical nature
+of HTML markup, a crude approximation to the formatting options of a given
+character is just to equate them with the stack of tag contexts to which
+the character belongs, as the figure shows.
+</p>
+
+<p align="center">
+<img src="html.png"
+alt="formatting contexts of characters in an HTML document"
+width="320" height="275"><br>
+<b>Fig. 1: Formatting contexts of characters in an HTML document.</b>
+</p>
+
+<p>
+HTML documents are then parsed as arrays of (character, format)
+pairs, where the format is the tag context as described above. The very high
+degree of redundancy in formatting information is taken care of by the
+use of Boost.Flyweight. This character-based representation makes it
+easy to manipulate the document: transposition and elimination of
+portions of text are trivial operations. As an example, the program
+reverses the text occupying the central portion of the document.
+Saving the result in HTML reduces to traversing the array of formatted
+characters and emitting opening/closing HTML tags as the context of adjacent
+characters varies.
+</p>
+
+<p>
+For the sake of brevity, the HTML parsing capabilities of this program
+are coarse: for instance, elements without end-tag (like &lt;BR&gt), character
+enconding and HTML entities (e.g. "&amp;copy;" for &copy;) 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>
+
+<p>
+See source code.
+</p>
+
+<p>
+If <code>T</code> is serializable (using
+Boost.Serialization),
+<code>flyweight&lt;T&gt;</code> is automatically
+serializable as well. The example program performs the following two
+complementary procedures:
+<ul>
+ <li>Read a text file as a <code>std::vector&lt;flyweight&lt;std::string&gt; &gt;</code>
+ and save the structure to a serialization file.
+ </li>
+ <li>Load a <code>std::vector&lt;flyweight&lt;std::string&gt; &gt;</code> from a
+ serialization file and write it as a text file.
+ </li>
+</ul>
+If you visually inspect the contents of any of the generated serialization files
+you can notice that no word appears twice; Boost.Flyweight implements some internal
+machinery that avoids duplicating output information when saving equal
+<code>flyweight</code> objects.
+</p>
+
+<h2><a name="example5">Example 5: performance comparison</a></h2>
+
+<p>
+See source code.
+</p>
+
+<p>
+This program measures the time and space performances of a simple
+string type against several differently configured <code>flyweight</code>
+instantations as used in a conventional task involving parsing a file and
+doing some manipulations on the parsed text.
+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.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="xxx.html"><img src="prev.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[not linked yet]</font>
+</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="xxx.html"><img src="next.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[not linked yet]</font>
+</a></div><br clear="all" style="clear: all;">
+<br clear="all" style="clear: all;">
+<br>
+
+<p>Revised November 12th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/html.png
==============================================================================
Binary file. No diff available.

Added: sandbox/flyweight/libs/flyweight/doc/index.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/index.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Index</title>
+<link rel="stylesheet" href="style.css" type="text/css">
+<link rel="start" href="index.html">
+<link rel="next" href="tutorial/index.html">
+</head>
+
+<body>
+<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost Flyweight Library</h1>
+
+<div class="prev_link"></div>
+<div class="up_link"></div>
+<div class="next_link"><a href="tutorial/index.html"><img src="next.gif" alt="tutorial" border="0"><br>
+Tutorial
+</a></div><br clear="all" style="clear: all;">
+
+<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
+within reasonable memory limits. Boost.Flyweight makes it easy to use this
+common programming idiom by providing the class template
+<code>flyweight&lt;T&gt;</code>, which acts as a drop-in replacement for
+<code>const T</code>.
+</p>
+
+<p>
+Learning to use Boost.Flyweight can be accomplished in a matter of minutes.
+When special needs arise, however, an extensive customization interface
+is provided which allows the user to control and extend the following aspects:
+<ul>
+ <li>Type tagging for separation of domains using the same basic
+ flyweight types.</li>
+ <li>Specification and parameterization of the so-called flyweight
+ factory.</li>
+ <li>Control of the factory instantiation procedure.</li>
+ <li>Specification of the internal synchronization mechanisms.</li>
+ <li>Flyweight tracking, allowing for the disposal of stored
+ values when no longer referenced by any flyweight object.</li>
+</ul>
+</p>
+
+<h2>Contents</h2>
+
+<ul>
+ <li>
Tutorial</li>
+ <li>Reference</li>
+ <li><font color="#ff0000">[more to come]</font></li>
+ <li>Examples</li>
+ <li><font color="#ff0000">[more to come]</font></li>
+ <li>Acknowledgements</li>
+</ul>
+
+<hr>
+
+<div class="prev_link"></div>
+<div class="up_link"></div>
+<div class="next_link"><a href="tutorial/index.html"><img src="next.gif" alt="tutorial" border="0"><br>
+Tutorial
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 20th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/next.gif
==============================================================================
Binary file. No diff available.

Added: sandbox/flyweight/libs/flyweight/doc/prev.gif
==============================================================================
Binary file. No diff available.

Added: sandbox/flyweight/libs/flyweight/doc/reference/factories.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/factories.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,581 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Factories reference</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="tags.html">
+<link rel="up" href="index.html">
+<link rel="next" href="holders.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight
+Factories reference</h1>
+
+<div class="prev_link"><a href="tags.html"><img src="../prev.gif" alt="tags" border="0"><br>
+Tags
+</a></div>
+<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="holders.html"><img src="../next.gif" alt="holders" border="0"><br>
+Holders
+</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>
+ <li>
Factories and factory specifiers</li>
+ <li><a href="#factory_tag_synopsis">Header
+ <code>"boost/flyweight/factory_tag.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template is_factory</li>
+ <li>Class template factory</li>
+ </ul>
+ </li>
+ <li><a href="#hashed_factory_fwd_synopsis">Header
+ <code>"boost/flyweight/hashed_factory_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#hashed_factory_synopsis">Header
+ <code>"boost/flyweight/hashed_factory.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template hashed_factory_class</li>
+ <li>Class template hashed_factory</li>
+ </ul>
+ </li>
+ <li><a href="#set_factory_fwd_synopsis">Header
+ <code>"boost/flyweight/set_factory_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#set_factory_synopsis">Header
+ <code>"boost/flyweight/set_factory.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template set_factory_class</li>
+ <li>Class template set_factory</li>
+ </ul>
+ </li>
+ <li><a href="#assoc_container_factory_fwd_synopsis">Header
+ <code>"boost/flyweight/assoc_container_factory_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#assoc_container_factory_synopsis">Header
+ <code>"boost/flyweight/assoc_container_factory.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template assoc_container_factory_class</li>
+ <li>Class template assoc_container_factory</li>
+ </ul>
+ </li>
+</ul>
+
+<h2><a name="factory">Factories and factory specifiers</a></h2>
+
+<p>
+Given a type <code>Value</code> and an
+Assignable
+type <code>Entry</code> implicitly convertible to <code>const Value&amp;</code>, a
+<i>factory of <code>Entry</code> elements</i> (implicitly associated to
+<code>Value</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
+can be stored simultaneously in the factory. Different factory types can
+use different equivalence relations.
+</p>
+
+<p>
+In the following table, <code>Factory</code> is a factory of elements
+of type <code>Entry</code>, <code>f</code> denotes an object of type <code>Factory</code>,
+<code>x</code> is an object of type <code>Entry</code> and <code>h</code> is a
+value of <code>Factory::handle_type</code>.
+</p>
+
+<p align="center">
+<table cellspacing="0">
+ <caption><b>Factory requirements.</b></caption>
+<tr>
+ <th align="center">expression</th>
+ <th align="center">return type</th>
+ <th align="center">assertion/note<br>pre/post-condition</th>
+</tr>
+<tr>
+ <td><code>Factory::handle_type</code></td>
+ <td>handle to elements of type <code>T</code><br>
+ stored in the factory
+ </td>
+ <td><code>handle_type</code> is
+ Assignable
+ and its copy and<br>
+ assignment operations never throw an exception.
+ </td>
+</tr>
+<tr class="odd_tr">
+ <td><code>f.insert(x);</code></td>
+ <td><code>handle_type</code></td>
+ <td>Inserts a copy of <code>x</code> if there is no equivalent entry in <code>f</code>;<br>
+ returns a handle to the inserted or equivalent element.
+ </td>
+</tr>
+<tr>
+ <td><code>f.erase(h);</code></td>
+ <td><code>void</code></td>
+ <td>Erases the element associated to <code>h</code>.</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>
+</tr>
+</table>
+</p>
+
+<p>
+Additionally to the basic thread-safety guarantee which is implicitly assumed
+for most classes including the majority of components of the
+C++ standard library, it is required that the member function <code>entry</code>
+can be invoked simultaneously from different threads, even in the presence
+of concurrent accesses to <code>insert</code> and <code>erase</code> (as long
+as the entry returned by <code>entry</code> is not the one which is being
+erased).
+</p>
+
+<p>
+A type <code>S</code> is said to be a <i>factory specifier</i> if:
+<ol>
+ <li>One of the following conditions is satisfied:
+ <ol type="a">
+ <li>is_factory<S>::type is
+ boost::mpl::true_,</li>
+ <li><code>S</code> is of the form factory<S'>.</li>
+ </ol>
+ </li>
+ <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>).
+ </li>
+</ol>
+</p>
+
+<h2><a name="factory_tag_synopsis">Header
+"boost/flyweight/factory_tag.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>factory_marker</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>is_factory</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>factory</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<h3><a name="is_factory">Class template <code>is_factory</code></h3>
+
+<p>
+Unless specialized by the user, <code>is_factory&lt;T&gt;::type</code> is
+boost::mpl::true_
+if <code>T</code> is derived from <code>factory_marker</code>, and it is
+boost::mpl::false_
+otherwise.
+</p>
+
+<h3><a name="factory_construct">Class template <code>factory</code></h3>
+
+<p>
+<code>factory&lt;T&gt;</code> is a syntactic construct meant to indicate
+that <code>T</code> is a factory specifier without resorting to the
+mechanisms provided by the <code>is_factory</code> class template.
+</p>
+
+<h2><a name="hashed_factory_fwd_synopsis">Header
+"boost/flyweight/hashed_factory_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</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>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>
+<span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>hashed_factory_class</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</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>
+<span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>hashed_factory</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>hashed_factory_fwd.hpp</code> forward declares the class templates
+hashed_factory_class
+and hashed_factory.
+</p>
+
+<h2><a name="hashed_factory_synopsis">Header
+"boost/flyweight/hashed_factory.hpp" synopsis</a></h2>
+
+<h3><a name="hashed_factory_class">Class template <code>hashed_factory_class</code></a></h3>
+
+<p>
+<code>hashed_factory_class</code> is a Factory
+implemented with a hashed container.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</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>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>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>hashed_factory_class</span>
+<span class=special>{</span>
+<span class=keyword>public</span><span class=special>:</span>
+ <span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>handle_type</span><span class=special>;</span>
+
+ <span class=identifier>handle_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>Entry</span><span class=special>&amp;</span> <span class=identifier>x</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=keyword>const</span> <span class=identifier>Entry</span><span class=special>&amp;</span> <span class=identifier>entry</span><span class=special>(</span><span class=identifier>handle_type</span> <span class=identifier>h</span><span class=special>);</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+<code>Hash</code> is a
+<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
+Constructible</code></a>
+Unary Function
+taking a single argument of type <code>Value</code> and returning a
+value of type <code>std::size_t</code> in the range
+<code>[0, std::numeric_limits&lt;std::size_t&gt;::max())</code>.
+<code>Pred</code> is a
+<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"><code>Default
+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
+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
+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&lt;Value&gt;</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&lt;Entry&gt;</code>. The internal
+hashed container upon which <code>hashed_factory_class</code> is based is
+constructed with default initialized objects of type <code>Hash</code>,
+<code>Pred</code> and <code>Allocator</code>.
+</p>
+
+<h3><a name="hashed_factory">Class template <code>hashed_factory</code></a></h3>
+
+<p>
+Factory Specifier for hashed_factory_class.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</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>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>hashed_factory</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+<code>hashed_factory&lt;Hash,Pred,Allocator&gt;</code> is an
+<a href="../../../mpl/doc/refmanual/metafunction-class.html"><code>MPL Metafunction
+Class</code></a> such that the type
+</p>
+
+<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>&lt;</span>
+ <span class=identifier>hashed_factory</span><span class=special>&lt;</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>&gt;,</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+<span class=special>&gt;::</span><span class=identifier>type</span>
+</pre></blockquote>
+
+<p>
+is the same as
+</p>
+
+<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>&lt;</span>
+ <span class=identifier>hashed_factory_class</span><span class=special>&lt;</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>&gt;,</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+<span class=special>&gt;::</span><span class=identifier>type</span>
+</pre></blockquote>
+
+<p>
+This implies that <code>Hash</code>, <code>Pred</code> and <code>Allocator</code>
+can be
+<a href="../../../mpl/doc/refmanual/placeholder-expression.html"><code>MPL
+Placeholder Expressions</code></a> resolving to the actual types used by
+<code>hashed_factory_class</code>.
+</p>
+
+<h2><a name="set_factory_fwd_synopsis">Header
+"boost/flyweight/set_factory_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</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>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>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>set_factory_class</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</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>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>set_factory</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>set_factory_fwd.hpp</code> forward declares the class templates
+set_factory_class
+and set_factory.
+</p>
+
+<h2><a name="set_factory_synopsis">Header
+"boost/flyweight/set_factory.hpp" synopsis</a></h2>
+
+<h3><a name="set_factory_class">Class template <code>set_factory_class</code></a></h3>
+
+<p>
+<code>set_factory_class</code> is a Factory
+implemented on top of an orderded associative container.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</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>Compare</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Allocator</span>
+<span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>set_factory_class</span>
+<span class=special>{</span>
+<span class=keyword>public</span><span class=special>:</span>
+ <span class=keyword>typedef</span> <b>implementation defined</b> <span class=identifier>handle_type</span><span class=special>;</span>
+
+ <span class=identifier>handle_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>Entry</span><span class=special>&amp;</span> <span class=identifier>x</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=keyword>const</span> <span class=identifier>Entry</span><span class=special>&amp;</span> <span class=identifier>entry</span><span class=special>(</span><span class=identifier>handle_type</span> <span class=identifier>h</span><span class=special>);</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+<code>Compare</code> is a
+<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>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&lt;Value&gt;</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&lt;Entry&gt;</code>. The internal
+container upon which <code>set_factory_class</code> is based is
+constructed with default initialized objects of type <code>Compare</code>
+and <code>Allocator</code>.
+</p>
+
+<h3><a name="set_factory">Class template <code>set_factory</code></a></h3>
+
+<p>
+Factory Specifier for set_factory_class.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</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>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>set_factory</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+<code>set_factory&lt;Compare,Allocator&gt;</code> is an
+<a href="../../../mpl/doc/refmanual/metafunction-class.html"><code>MPL Metafunction
+Class</code></a> such that the type
+</p>
+
+<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>&lt;</span>
+ <span class=identifier>set_factory</span><span class=special>&lt;</span><span class=identifier>Compare</span><span class=special>,</span><span class=identifier>Allocator</span><span class=special>&gt;,</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+<span class=special>&gt;::</span><span class=identifier>type</span>
+</pre></blockquote>
+
+<p>
+is the same as
+</p>
+
+<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>&lt;</span>
+ <span class=identifier>set_factory_class</span><span class=special>&lt;</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>&gt;,</span>
+ <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span>
+<span class=special>&gt;::</span><span class=identifier>type</span>
+</pre></blockquote>
+
+<p>
+This implies that <code>Compare</code> and <code>Allocator</code>
+can be
+<a href="../../../mpl/doc/refmanual/placeholder-expression.html"><code>MPL
+Placeholder Expressions</code></a> resolving to the actual types used by
+<code>set_factory_class</code>.
+</p>
+
+<h2><a name="assoc_container_factory_fwd_synopsis">Header
+"boost/flyweight/assoc_container_factory_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Container</span><span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>assoc_container_factory_class</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>ContainerSpecifier</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>assoc_container_factory</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>assoc_container_factory_fwd.hpp</code> forward declares the class templates
+assoc_container_factory_class
+and assoc_container_factory.
+</p>
+
+<h2><a name="assoc_container_factory_synopsis">Header
+"boost/flyweight/assoc_container_factory.hpp" synopsis</a></h2>
+
+<h3><a name="assoc_container_factory_class">Class template <code>assoc_container_factory_class</code></a></h3>
+
+<p>
+<code>assoc_container_factory_class</code> wraps a suitable associative container
+to provide a Factory interface.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Container</span><span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>assoc_container_factory_class</span>
+<span class=special>{</span>
+<span class=keyword>public</span><span class=special>:</span>
+ <span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Container</span><span class=special>::</span><span class=identifier>iterator</span> <span class=identifier>handle_type</span><span class=special>;</span>
+
+ <span class=identifier>handle_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>Container</span><span class=special>::</span><span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>x</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=keyword>const</span> <span class=keyword>typename</span> <span class=identifier>Container</span><span class=special>::</span><span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>entry</span><span class=special>(</span><span class=identifier>handle_type</span> <span class=identifier>h</span><span class=special>);</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+<code>Container</code> must be an (ordered or unordered) associative container
+such that
+<ol>
+ <li><code>Container::key_type</code> is the same as
+ <code>Container::value_type</code> (which is the entry type associated to
+ the factory).
+ </li>
+ <li>Unique keys (rather than equivalent keys) are supported.</li>
+ <li><code>Container</code> is <i>stable</i>, i.e. its iterators are not
+ invalidated upon insert or erase operations.</li>
+</ol>
+The equivalence relation associated to <code>assoc_container_factory_class</code>
+is the one induced by <code>Container</code>. If equivalence of elements
+of <code>Container::value_type</code> is determined solely on the basis of a
+type <code>value_type'</code> to which <code>value_type</code> is
+implicitly convertible, then <code>assoc_container_factory_class</code> is
+a factory of entries of type <code>value_type</code> implicitly associated to
+<code>value_type'</code>. For example, the instantiation
+</p>
+
+<blockquote><pre>
+<span class=identifier>assoc_container_factory_class</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>set</span><span class=special>&lt;</span><span class=identifier>derived</span><span class=special>,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special>&lt;</span><span class=identifier>base</span><span class=special>&gt;</span> <span class=special>&gt;</span> <span class=comment>// derived inherits from base</span>
+<span class=special>&gt;</span>
+</pre></blockquote>
+
+<p>
+is a factory of <code>derived</code> elements implicitly associated to
+<code>base</code>.
+</p>
+
+<h3><a name="assoc_container_factory">Class template <code>assoc_container_factory</code></a></h3>
+
+<p>
+Factory Specifier for assoc_container_factory_class.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>ContainerSpecifier</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>assoc_container_factory</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+<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>assoc_container_factory_class&lt;Container&gt;</code> is a factory
+of <code>Entry</code> elements implicitly associated to <code>Value</code>.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="tags.html"><img src="../prev.gif" alt="tags" border="0"><br>
+Tags
+</a></div>
+<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="holders.html"><img src="../next.gif" alt="holders" border="0"><br>
+Holders
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 26th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/flyweight.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,561 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - flyweight reference</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="index.html">
+<link rel="up" href="index.html">
+<link rel="next" href="tags.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight
+<code>flyweight</code> reference</h1>
+
+<div class="prev_link"><a href="index.html"><img src="../prev.gif" alt="Boost.Flyweight reference" border="0"><br>
+Boost.Flyweight reference
+</a></div>
+<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
+</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>
+ <li><a href="#flyweight_fwd_synopsis">Header
+ <code>"boost/flyweight/flyweight_fwd.hpp"</code> synopsis</a></li>
+ <li><a href="#synopsis">Header
+ <code>"boost/flyweight/flyweight.hpp"</code> synopsis</a>
+ <ul>
+ <li>
Class template flyweight
+ <ul>
+ <li>Instantiation types</li>
+ <li>Constructors, copy and assignment</li>
+ <li>Convertibility to the underlying type</li>
+ <li>Modifiers</li>
+ <li>Comparison operators</li>
+ <li>Specialized algorithms</li>
+ <li>Configuration macros</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li><a href="#serialize_synopsis">Header
+ <code>"boost/flyweight/serialize.hpp"</code> synopsis</a>
+ <ul>
+ <li>Serialization</li>
+ </ul>
+ </li>
+</ul>
+
+<h2>
+<a name="#flyweight_fwd_synopsis">Header
+"boost/flyweight/flyweight_fwd.hpp"
+synopsis</a>
+</h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>T</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Arg1</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Arg2</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Arg3</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Arg4</span><span class=special>=</span><b>implementation defined</b><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Arg5</span><span class=special>=</span><b>implementation defined</b>
+<span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>flyweight</span><span class=special>;</span>
+
+<span class=comment>// comparison:
+
+// <b>OP</b> is any of ==,&lt;,!=,&gt;,&gt;=,&lt;=</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>T1</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg11</span><span class=special>,...,</span><span class=keyword>typename</span> <span class=identifier>Arg15</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>T2</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg21</span><span class=special>,...,</span><span class=keyword>typename</span> <span class=identifier>Arg25</span>
+<span class=special>&gt;</span>
+<span class=keyword>bool</span> <span class=keyword>operator</span> <span class=identifier><b><i>OP</i></b></span><span class=special>(</span>
+ <span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T1</span><span class=special>,</span><span class=identifier>Arg11</span><span class=special>,...,</span><span class=identifier>Arg15</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
+ <span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T2</span><span class=special>,</span><span class=identifier>Arg21</span><span class=special>,...,</span><span class=identifier>Arg25</span><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>);</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>T1</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg11</span><span class=special>,...,</span><span class=keyword>typename</span> <span class=identifier>Arg15</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>T2</span>
+<span class=special>&gt;</span>
+<span class=keyword>bool</span> <span class=keyword>operator</span> <span class=identifier><b><i>OP</i></b></span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T1</span><span class=special>,</span><span class=identifier>Arg11</span><span class=special>,...,</span><span class=identifier>Arg15</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>T2</span><span class=special>&amp;</span> <span class=identifier>y</span><span class=special>);</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>T1</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>T2</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg21</span><span class=special>,...,</span><span class=keyword>typename</span> <span class=identifier>Arg25</span>
+<span class=special>&gt;</span>
+<span class=keyword>bool</span> <span class=keyword>operator</span> <span class=identifier><b><i>OP</i></b></span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>T1</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T2</span><span class=special>,</span><span class=identifier>Arg21</span><span class=special>,...,</span><span class=identifier>Arg25</span><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>);</span>
+
+<span class=comment>// specialized algorithms:</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</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>Arg5</span><span class=special>&gt;</span>
+<span class=keyword>inline</span> <span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span>
+ <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>,...,</span><span class=identifier>Arg5</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>,...,</span><span class=identifier>Arg5</span><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>);</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>ElemType</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Traits</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>T</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>Arg5</span>
+<span class=special>&gt;</span>
+<span class=keyword>inline</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>basic_ostream</span><span class=special>&lt;</span><span class=identifier>ElemType</span><span class=special>,</span><span class=identifier>Traits</span><span class=special>&gt;&amp;</span> <span class=keyword>operator</span><span class=special>&lt;&lt;(</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>basic_ostream</span><span class=special>&lt;</span><span class=identifier>ElemType</span><span class=special>,</span><span class=identifier>Traits</span><span class=special>&gt;&amp;</span> <span class=identifier>out</span><span class=special>,</span>
+ <span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>,...,</span><span class=identifier>Arg5</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>);</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>ElemType</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Traits</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>T</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>Arg5</span>
+<span class=special>&gt;</span>
+<span class=keyword>inline</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>basic_ostream</span><span class=special>&lt;</span><span class=identifier>ElemType</span><span class=special>,</span><span class=identifier>Traits</span><span class=special>&gt;&amp;</span> <span class=keyword>operator</span><span class=special>&gt;&gt;(</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>basic_istream</span><span class=special>&lt;</span><span class=identifier>ElemType</span><span class=special>,</span><span class=identifier>Traits</span><span class=special>&gt;&amp;</span> <span class=identifier>in</span><span class=special>,</span>
+ <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>,...,</span><span class=identifier>Arg5</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>);</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=keyword>using</span> <span class=identifier>flyweights</span><span class=special>::</span><span class=identifier>flyweight</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>flyweight_fwd.hpp</code> forward declares the class template
+flyweight and its associated global functions.
+</p>
+
+<h2>
+<a name="synopsis">Header
+"boost/flyweight/flyweight.hpp"
+synopsis</a>
+</h2>
+
+<h3><a name="flyweight">
+Class template <code>flyweight</code>
+</a></h3>
+
+<p>
+Objects of type <code>flyweight&lt;T,...&gt;</code> provide access to immutable
+values of type <code>T</code>, with the following advantages over using
+plain <code>T</code> objects:
+<ul>
+ <li>Flyweight objects with equivalent value share the same representation
+ (the associated <code>T</code> object).
+ </li>
+ <li>The size of flyweights is typically that of a pointer, which is in general
+ smaller than <code>sizeof(T)</code>.
+ </li>
+</ul>
+
+So, if the level of redundancy (ratio of total objects to different values)
+is high enough, substituting <code>flyweight&lt;T,...&gt;</code> for
+<code>T</code> results in a reduction in memory usage.
+</p>
+
+<p>
+<code>flyweight</code> is parameterized according to the following aspects:
+<ul>
+ <li>The factory class used to store
+ and retrieve the shared value objects.
+ </li>
+ <li>The type of holder used to
+ instantiate the flyweight factory, which is unique for each
+ specialization of the <code>flyweight</code> class template.
+ </li>
+ <li>A locking policy determining
+ the synchronization mechanisms for internal access to shared resources.
+ </li>
+ <li>A tracking policy which controls
+ how values are treated when all their associated flyweight objects are
+ destroyed.
+ </li>
+</ul>
+In what follows, we implicitly assume that <code>T</code> equivalence
+refers to the equivalence relationship induced by the factory class used.
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>T</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>typename</span> <span class=identifier>Arg3</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg4</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Arg5</span>
+<span class=special>&gt;</span>
+<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=comment>// construct/copy/destroy:</span>
+
+ <span class=identifier>flyweight</span><span class=special>();</span>
+ <span class=identifier>flyweight</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
+ <span class=identifier>flyweight</span><span class=special>(</span><span class=identifier>flyweight</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
+
+ <span class=comment>// forwarding constructors:
+ // n is implementation defined. All combinations of constant
+ // and non constant reference arguments are provided.</span>
+
+ <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T0</span><span class=special>&gt;</span>
+ <span class=keyword>explicit</span> <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>&amp;</span> <span class=identifier>t0</span><span class=special>);</span>
+ <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T0</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>T1</span><span class=special>&gt;</span>
+ <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>&amp;</span> <span class=identifier>t0</span><span class=special>,[</span><span class=keyword>const</span><span class=special>]</span> <span class=identifier>T1</span><span class=special>&amp;</span> <span class=identifier>t1</span><span class=special>);</span>
+ <span class=special>...</span>
+ <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T0</span><span class=special>,...,</span><span class=keyword>typename</span> <span class=identifier>Tn</span><span class=special>-</span><span class=number>1</span><span class=special>&gt;</span>
+ <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>&amp;</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>&amp;</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>&amp;</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <span class=identifier>flyweight</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
+ <span class=identifier>flyweight</span><span class=special>&amp;</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <span class=identifier>T</span><span class=special>&amp;</span> <span class=identifier>t</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>&amp;</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>&amp;()</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>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<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
+Assignable
+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:
+<ul>
+ <li>A tag,</li>
+ <li>a factory specifier,</li>
+ <li>a holder specifier,</li>
+ <li>a locking policy,</li>
+ <li>a tracking policy.</li>
+</ul>
+No aspect can be specified twice. The default configuration arguments are:
+<ul>
+ <li>No tagging,</li>
+ <li>hashed_factory<>,</li>
+ <li>static_holder,</li>
+ <li>simple_locking,</li>
+ <li>refcounted tracking policy.</li>
+</ul>
+</p>
+
+<h4><a name="constructors">Constructors, copy and assignment</a></h4>
+
+<code>flyweight();</code>
+
+<blockquote>
+<b>Requires:</b> <code>T</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>.
+</blockquote>
+
+<code>flyweight(const flyweight&amp; x);<br>
+flyweight(flyweight&amp; x);</code>
+
+<blockquote>
+<b>Effects:</b> Constructs a <code>flyweight</code> object with value
+<code>x.get()</code>.<br>
+<b>Exception safety:</b> <code>nothrow</code>.
+</blockquote>
+
+<a name="#fwd_ctors">
+<code>template&lt;typename T0&gt;<br>
+explicit flyweight([const] T0&amp; t0);<br>
+template&lt;typename T0,typename T1&gt;<br>
+flyweight([const] T0&amp; t0,[const] T1&amp; t1);<br>
+...<br>
+template&lt;typename T0,...,typename Tn-1&gt;<br>
+flyweight([const] T0&amp; t0,...,[const] Tn-1&amp; tn-1);</code></a>
+
+<blockquote>
+<b>Effects:</b> Constructs a <code>flyweight</code> object with value
+<code>T(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.
+</blockquote>
+
+<code>flyweight&amp; operator=(const flyweight&amp; x);</code>
+
+<blockquote>
+<b>Effects:</b> Associates the <code>flyweight</code> object with the same value
+as <code>x</code>.<br>
+<b>Returns:</b> <code>*this</code>.<br>
+<b>Exception safety:</b> <code>nothrow</code>.
+</blockquote>
+
+<code>flyweight&amp; operator=(const T&amp; t);</code>
+
+<blockquote>
+<b>Effects:</b> Associates the <code>flyweight</code> object with value
+<code>t</code>.<br>
+<b>Returns:</b> <code>*this</code>.<br>
+</blockquote>
+
+<h4><a name="convertibility">Convertibility to the underlying type</a></h4>
+
+<code>const T&amp; get()const;<br>
+operator const T&amp;()const;</code>
+
+<blockquote>
+<b>Return:</b> The value associated to the <code>flyweight</code>
+object.<br>
+<b>Exception safety:</b> <code>nothrow</code>.
+</blockquote>
+
+<h4><a name="modifiers">Modifiers</a></h4>
+
+<code>void swap(flyweight&amp; 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>Exception safety:</b> <code>nothrow</code>.
+</blockquote>
+
+<h4><a name="comparison">Comparison operators</a></h4>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,typename Arg11,...,typename Arg15,<br>
+&nbsp;&nbsp;typename T2,typename Arg21,...,typename Arg25<br>
+&gt;<br>
+bool operator ==(<br>
+&nbsp;&nbsp;const flyweight&lt;T1,Arg11,...,Arg15&gt;&amp; x,<br>
+&nbsp;&nbsp;const flyweight&lt;T2,Arg21,...,Arg25&gt;&amp; y);</code>
+
+<blockquote>
+<b>Returns:</b> If <code>x</code> and <code>y</code> are of the same type, returns
+<code>true</code> if and only if they are associated to the same value; if
+<code>x</code> and <code>y</code> have different types, returns
+<code>x.get()==y.get()</code>.<br>
+<b>Exception safety:</b> If <code>x</code> and <code>y</code> are of the same type,
+<code>nothrow</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,typename Arg11,...,typename Arg15,<br>
+&nbsp;&nbsp;typename T2<br>
+&gt;<br>
+bool operator ==(const flyweight&lt;T1,Arg11,...,Arg15&gt;&amp; x,const T2&amp; y);</code>
+
+<blockquote>
+<b>Returns:</b> <code>x.get()==y</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,<br>
+&nbsp;&nbsp;typename T2,typename Arg21,...,typename Arg25<br>
+&gt;<br>
+bool operator ==(const T1&amp; x,const flyweight&lt;T2,Arg21,...,Arg25&gt;&amp; y);</code>
+
+<blockquote>
+<b>Returns:</b> <code>x()==y.get()</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,typename Arg11,...,typename Arg15,<br>
+&nbsp;&nbsp;typename T2,typename Arg21,...,typename Arg25<br>
+&gt;<br>
+bool operator &lt;(<br>
+&nbsp;&nbsp;const flyweight&lt;T1,Arg11,...,Arg15&gt;&amp; x,<br>
+&nbsp;&nbsp;const flyweight&lt;T2,Arg21,...,Arg25&gt;&amp; y);</code>
+
+<blockquote>
+<b>Returns:</b> <code>x.get()&lt;y.get()</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,typename Arg11,...,typename Arg15,<br>
+&nbsp;&nbsp;typename T2<br>
+&gt;<br>
+bool operator &lt;(const flyweight&lt;T1,Arg11,...,Arg15&gt;&amp; x,const T2&amp; y);</code>
+
+<blockquote>
+<b>Returns:</b> <code>x.get()&lt;y</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,<br>
+&nbsp;&nbsp;typename T2,typename Arg21,...,typename Arg25<br>
+&gt;<br>
+bool operator &lt;(const T1&amp; x,const flyweight&lt;T2,Arg21,...,Arg25&gt;&amp; y);</code>
+
+<blockquote>
+<b>Returns:</b> <code>x()&lt;y.get()</code>.
+</blockquote>
+
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename T1,typename Arg11,...,typename Arg15,<br>
+&nbsp;&nbsp;typename T2,typename Arg21,...,typename Arg25<br>
+&gt;<br>
+bool operator <b><i>OP</i></b>(<br>
+&nbsp;&nbsp;const flyweight&lt;T1,Arg11,...,Arg15&gt;&amp; x,<br>
+&nbsp;&nbsp;const flyweight&lt;T2,Arg21,...,Arg25&gt;&amp; y);<br>
+template&lt;<br>
+&nbsp;&nbsp;typename T1,typename Arg11,...,typename Arg15,<br>
+&nbsp;&nbsp;typename T2<br>
+&gt;<br>
+bool operator <b><i>OP</i></b>(const flyweight&lt;T1,Arg11,...,Arg15&gt;&amp; x,const T2&amp; y);</br>
+template&lt;<br>
+&nbsp;&nbsp;typename T1,<br>
+&nbsp;&nbsp;typename T2,typename Arg21,...,typename Arg25<br>
+&gt;<br>
+bool operator <b><i>OP</i></b>(const T1&amp; x,const flyweight&lt;T2,Arg21,...,Arg25&gt;&amp; y);</code>
+
+<p>
+(<code><b><i>OP</i></b></code> is any of <code>!=</code>, <code>></code>,
+<code>>=</code>, <code>&lt;=</code>.)
+</p>
+
+<blockquote>
+<b>Returns:</b> <code>true</code> if and only if
+<blockquote>
+<code>!(x==y)</code> (<code><b><i>OP</i></b></code> is <code>!=</code>),<br>
+<code>&nbsp;&nbsp;y&lt;&nbsp;x&nbsp;</code> (<code><b><i>OP</i></b></code> is <code>>&nbsp;</code>),<br>
+<code>!(x&lt;&nbsp;y)</code> (<code><b><i>OP</i></b></code> is <code>>=</code>),<br>
+<code>!(y&lt;&nbsp;x)</code> (<code><b><i>OP</i></b></code> is <code>&lt;=</code>).
+</blockquote>
+</blockquote>
+
+<h4><a name="specialized">Specialized algorithms</a></h4>
+
+<code>template&lt;typename T,typename Arg1,...,typename Arg5&gt;<br>
+inline void swap(<br>
+&nbsp;&nbsp;flyweight&lt;T,Arg1,...,Arg5&gt;&amp; x,flyweight&lt;T,Arg1,...,Arg5&gt;&amp; y);</code>
+
+<blockquote>
+<b>Effects:</b> <code>x.swap(y)</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename ElemType,typename Traits, <br>
+&nbsp;&nbsp;typename T,typename Arg1,...,typename Arg5<br>
+&gt;<br>
+inline std::basic_ostream&lt;ElemType,Traits&gt;&amp; operator&lt;&lt;(<br>
+&nbsp;&nbsp;std::basic_ostream&lt;ElemType,Traits&gt;&amp; out,<br>
+&nbsp;&nbsp;const flyweight&lt;T,Arg1,...,Arg5&gt;&amp; x);</code>
+
+<blockquote>
+<b>Effects:</b> <code>out&lt;&lt;x.get()</code>.<br>
+<b>Returns:</b> <code>out</code>.
+</blockquote>
+
+<code>template&lt;<br>
+&nbsp;&nbsp;typename ElemType,typename Traits, <br>
+&nbsp;&nbsp;typename T,typename Arg1,...,typename Arg5<br>
+&gt;<br>
+inline std::basic_ostream&lt;ElemType,Traits&gt;&amp; operator&gt;&gt;(<br>
+&nbsp;&nbsp;std::basic_istream&lt;ElemType,Traits&gt;&amp; in,<br>
+&nbsp;&nbsp;flyweight&lt;T,Arg1,...,Arg5&gt;&amp; x);</code>
+
+<blockquote>
+<b>Effects:</b> Reads an object of type <code>T</code> from <code>in</code>
+and assigns it to <code>x</code>.<br>
+<b>Returns:</b> <code>in</code>.
+</blockquote>
+
+<h4><a name="config_macros">Configuration macros</a></h4>
+
+<a name="limit_num_ctor_args">
+<code>BOOST_FLYWEIGHT_LIMIT_NUM_CTOR_ARGS</code></a>
+
+<blockquote>
+<b>Effects:</b> Globally define this macro to set the maximum number of
+arguments accepted by <code>flyweight</code>
+forwarding constructors, which by default
+is 5.
+</blockquote>
+
+<h2>
+<a name="serialize_synopsis">Header
+"boost/flyweight/serialize.hpp"
+synopsis</a>
+</h2>
+
+<p>
+<code>serialize.hpp</code> includes the necessary functionality for interoperability
+of <code>flyweight</code> with
+Boost.Serialization.
+</p>
+
+<h3><a name="serialization">Serialization</a></h3>
+
+<p>
+<code>flyweight</code>s can be archived and retrieved by means of
+Boost.Serialization. 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
+tracked by
+Boost.Serialization or not.
+</p>
+
+Operation: saving of a <code>flyweight</code> object <code>x</code> to an
+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
+part of this operation or of a previous saving operation of a <code>flyweight</code>
+object with the same value.<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>
+
+Operation: loading of a <code>flyweight</code> <code>x'</code> from an
+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>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>
+
+<hr>
+
+<div class="prev_link"><a href="index.html"><img src="../prev.gif" alt="Boost.Flyweight reference" border="0"><br>
+Boost.Flyweight reference
+</a></div>
+<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
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 26th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/reference/holders.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/holders.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,243 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Holders reference</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="factories.html">
+<link rel="up" href="index.html">
+<link rel="next" href="locking.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight
+Holders reference</h1>
+
+<div class="prev_link"><a href="factories.html"><img src="../prev.gif" alt="factories" border="0"><br>
+Factories
+</a></div>
+<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="locking.html"><img src="../next.gif" alt="locking policies" border="0"><br>
+Locking policies
+</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>
+ <li>
Holders and holder specifiers</li>
+ <li><a href="#holder_tag_synopsis">Header
+ <code>"boost/flyweight/holder_tag.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template is_holder</li>
+ <li>Class template holder</li>
+ </ul>
+ </li>
+ <li><a href="#static_holder_fwd_synopsis">Header
+ <code>"boost/flyweight/static_holder_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#static_holder_synopsis">Header
+ <code>"boost/flyweight/static_holder.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template static_holder_class</li>
+ <li>Class static_holder</li>
+ </ul>
+ </li>
+ <li><a href="#intermodule_holder_fwd_synopsis">Header
+ <code>"boost/flyweight/intermodule_holder_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#intermodule_holder_synopsis">Header
+ <code>"boost/flyweight/intermodule_holder.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template intermodule_holder_class</li>
+ <li>Class intermodule_holder</li>
+ </ul>
+ </li>
+</ul>
+
+<h2><a name="holder">Holders and holder specifiers</a></h2>
+
+<p>
+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
+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.
+</p>
+
+<p>
+A type <code>S</code> is a <i>holder specifier</i> if:
+<ol>
+ <li>One of the following conditions is satisfied:
+ <ol type="a">
+ <li>is_holder<S>::type is
+ boost::mpl::true_,</li>
+ <li><code>S</code> is of the form holder<S'>.</li>
+ </ol>
+ </li>
+ <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 type <code>C</code> resolves to
+ a holder of <code>C</code>.
+ </li>
+</ol>
+</p>
+
+<h2><a name="holder_tag_synopsis">Header
+"boost/flyweight/holder_tag.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>holder_marker</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>is_holder</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>holder</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<h3><a name="is_holder">Class template <code>is_holder</code></h3>
+
+<p>
+Unless specialized by the user, <code>is_holder&lt;T&gt;::type</code> is
+boost::mpl::true_
+if <code>T</code> is derived from <code>holder_marker</code>, and it is
+boost::mpl::false_
+otherwise.
+</p>
+
+<h3><a name="holder_construct">Class template <code>holder</code></h3>
+
+<p>
+<code>holder&lt;T&gt;</code> is a syntactic construct meant to indicate
+that <code>T</code> is a holder specifier without resorting to the
+mechanisms provided by the <code>is_holder</code> class template.
+</p>
+
+<h2><a name="static_holder_fwd_synopsis">Header
+"boost/flyweight/static_holder_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>C</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>static_holder_class</span><span class=special>;</span>
+
+<span class=keyword>struct</span> <span class=identifier>static_holder</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>static_holder_fwd.hpp</code> forward declares
+static_holder_class
+and static_holder.
+</p>
+
+<h2><a name="static_holder_synopsis">Header
+"boost/flyweight/static_holder.hpp" synopsis</a></h2>
+
+<h3><a name="static_holder_class">Class template <code>static_holder_class</code></a></h3>
+
+<p>
+<code>static_holder_class&lt;C&gt;</code> keeps its unique instance of <code>C</code> as a
+local static object.
+</p>
+
+<h3><a name="static_holder">Class <code>static_holder</code></a></h3>
+
+<p>
+Holder Specifier for static_holder_class.
+</p>
+
+<h2><a name="intermodule_holder_fwd_synopsis">Header
+"boost/flyweight/intermodule_holder_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>C</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>intermodule_holder_class</span><span class=special>;</span>
+
+<span class=keyword>struct</span> <span class=identifier>intermodule_holder</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>intermodule_holder_fwd.hpp</code> forward declares
+intermodule_holder_class
+and intermodule_holder.
+</p>
+
+<h2><a name="intermodule_holder_synopsis">Header
+"boost/flyweight/intermodule_holder.hpp" synopsis</a></h2>
+
+<h3><a name="intermodule_holder_class">Class template <code>intermodule_holder_class</code></a></h3>
+
+<p>
+<code>intermodule_holder_class&lt;C&gt;</code> maintains a <code>C</code>
+instance which is unique even across different dynamically linked modules of
+the program using this same type. In general, this guarantee is not provided by
+static_holder_class, as most
+C++ implementations are not able to merge duplicates of static variables stored
+in different dynamic modules of a program.
+</p>
+
+<h3><a name="intermodule_holder">Class <code>intermodule_holder</code></a></h3>
+
+<p>
+Holder Specifier for intermodule_holder_class.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="factories.html"><img src="../prev.gif" alt="factories" border="0"><br>
+Factories
+</a></div>
+<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="locking.html"><img src="../next.gif" alt="locking policies" border="0"><br>
+Locking policies
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 27th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/reference/index.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/index.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,156 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Reference</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="xxx.html">
+<link rel="up" href="../index.html">
+<link rel="next" href="../tutorial/lambda_expressions.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" 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>
+Annex: MPL lambda expressions
+</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="flyweight.html"><img src="../next.gif" alt="flyweight reference" border="0"><br>
+<code>flyweight</code> reference
+</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>
+ <li>
Header summary</li>
+ <li><a href="#flyweight_synopsis">Header
+ <code>"boost/flyweight.hpp"</code> synopsis</a></li>
+ <li>Class template flyweight</li>
+ <li>Tags</li>
+ <li>Factories</li>
+ <li>Holders</li>
+ <li>Locking policies</li>
+ <li>Tracking policies</li>
+</ul>
+
+<h2><a name="headers">Header summary</a></h2>
+
+<p>
+Boost.Flyweight comprises the following public headers:
+<ul>
+ <li>"boost/flyweight.hpp"</li>
+ <li>Class template <code>flyweight</code>
+ <ul>
+ <li>"boost/flyweight/flyweight_fwd.hpp"</li>
+ <li>"boost/flyweight/flyweight.hpp"</li>
+ <li>"boost/flyweight/flyweight_serialize.hpp"</li>
+ </ul>
+ </li>
+ <li>Tags
+ <ul>
+ <li>"boost/flyweight/tag.hpp"</li>
+ </ul>
+ </li>
+ <li>Factories
+ <ul>
+ <li>"boost/flyweight/factory_tag.hpp"</li>
+ <li>"boost/flyweight/hashed_factory_fwd.hpp"</li>
+ <li>"boost/flyweight/hashed_factory.hpp"</li>
+ <li>"boost/flyweight/set_factory_fwd.hpp"</li>
+ <li>"boost/flyweight/set_factory.hpp"</li>
+ <li>"boost/flyweight/assoc_container_factory_fwd.hpp"</li>
+ <li>"boost/flyweight/assoc_container_factory.hpp"</li>
+ </ul>
+ </li>
+ <li>Holders
+ <ul>
+ <li>"boost/flyweight/holder_tag.hpp"</li>
+ <li>"boost/flyweight/static_holder_fwd.hpp"</li>
+ <li>"boost/flyweight/static_holder.hpp"</li>
+ <li>"boost/flyweight/intermodule_holder_fwd.hpp"</li>
+ <li>"boost/flyweight/intermodule_holder.hpp"</li>
+ </ul>
+ </li>
+ <li>Locking policies
+ <ul>
+ <li>"boost/flyweight/locking_tag.hpp"</li>
+ <li>"boost/flyweight/simple_locking_fwd.hpp"</li>
+ <li>"boost/flyweight/simple_locking.hpp"</li>
+ <li>"boost/flyweight/no_locking_fwd.hpp"</li>
+ <li>"boost/flyweight/no_locking.hpp"</li>
+ </ul>
+ </li>
+ <li>Tracking policies
+ <ul>
+ <li>"boost/flyweight/tracking_tag.hpp"</li>
+ <li>"boost/flyweight/refcounted_fwd.hpp"</li>
+ <li>"boost/flyweight/refcounted.hpp"</li>
+ <li>"boost/flyweight/no_tracking_fwd.hpp"</li>
+ <li>"boost/flyweight/no_tracking.hpp"</li>
+ </ul>
+ </li>
+</ul>
+</p>
+
+<p>
+In order to use the serialization capabilities of Boost.Flyweight,
+the appropriate Boost.Serialization library module must be linked. Other
+than that, Boost.Flyweight is a header-only library, requiring no additional
+object modules.
+</p>
+
+<h2>
+<a name="#flyweight_synopsis">Header
+"boost/flyweight.hpp"
+synopsis</a>
+</h2>
+
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>hashed_factory</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>refcounted</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>simple_locking</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>static_holder</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+</pre></blockquote>
+
+<p>
+This convenience header includes the main class template
+flyweight along with
+the default components used by <code>flyweight</code>.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="../tutorial/lambda_expressions.html"><img src="../prev.gif" alt="annex: MPL lambda expressions" border="0"><br>
+Annex: MPL lambda expressions
+</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="flyweight.html"><img src="../next.gif" alt="flyweight reference" border="0"><br>
+<code>flyweight</code> reference
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised August 16th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/reference/locking.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/locking.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,289 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Locking policies reference</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="factories.html">
+<link rel="up" href="index.html">
+<link rel="next" href="tracking.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight
+Locking policies reference</h1>
+
+<div class="prev_link"><a href="holders.html"><img src="../prev.gif" alt="holders" border="0"><br>
+Holders
+</a></div>
+<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="tracking.html"><img src="../next.gif" alt="tracking policies" border="0"><br>
+Tracking policies
+</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>
+ <li>
Preliminary concepts</li>
+ <li>Locking policies</li>
+ <li><a href="#tracking_tag_synopsis">Header
+ <code>"boost/flyweight/tracking_tag.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template is_tracking</li>
+ <li>Class template tracking</li>
+ </ul>
+ </li>
+ <li><a href="#simple_locking_fwd_synopsis">Header
+ <code>"boost/flyweight/simple_locking_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#simple_locking_synopsis">Header
+ <code>"boost/flyweight/simple_locking.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class simple_locking</li>
+ </ul>
+ </li>
+ <li><a href="#no_locking_fwd_synopsis">Header
+ <code>"boost/flyweight/no_locking_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#no_locking_synopsis">Header
+ <code>"boost/flyweight/no_locking.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class no_locking</li>
+ </ul>
+ </li>
+</ul>
+
+<h2><a name="preliminary">Preliminary concepts</a></h2>
+
+<p>
+A <i>mutex</i> is a type whose objects can be in either of two states, called
+locked and unlocked, with the property that when a thread A has locked a
+mutex <code>m</code> and a different thread B tries to lock <code>m</code>,
+B is blocked until A unlocks <code>m</code>. Additionally, a mutex is said to
+support <i>recursive locking</i> if a thread can succesfully invoke the locking
+operation for a mutex already locked by this same thread; in this case, it is
+required that the thread execute as many unlock operations as lock
+operations it has performed for the mutex to become effectively unlocked.
+A <i>scoped lock</i> is a
+type associated to some mutex type whose objects do the locking/unlocking
+of a mutex on construction/destruction time.
+</p>
+
+<p>
+In the following table, <code>Mutex</code> is a mutex type, <code>m</code>
+is an object of type <code>Mutex</code>, <code>Lock</code> is a scoped lock
+associated to <code>Mutex</code> and <code>lk</code> is a value of
+<code>Lock</code>.
+
+<p align="center">
+<table cellspacing="0">
+ <caption><b>Mutex and Scoped Lock requirements.</b></caption>
+<tr>
+ <th align="center">expression</th>
+ <th align="center">return type</th>
+ <th align="center">assertion/note<br>pre/post-condition</th>
+</tr>
+<tr>
+ <td><code>Mutex m;</code></td>
+ <td>&nbsp;</td>
+ <td>Post: <code>m</code> is unlocked.
+ </td>
+</tr>
+<tr class="odd_tr">
+ <td><code>(&m)->~Mutex();</td>
+ <td><code>void</code></td>
+ <td>Pre: <code>m</code> is unlocked.</td>
+</tr>
+<tr>
+ <td><code>Lock lk(m);</code></td>
+ <td>&nbsp;</td>
+ <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>void</code></td>
+ <td>Unlocks the mutex associated to <code>lk</code>.</td>
+</tr>
+</table>
+</p>
+
+<p>
+These concepts are very similar, but not entirely equivalent, to
+the homonym ones described in the
+<a href="../../../../doc/html/thread/concepts.htm">Boost Thread
+Library</a>.
+</p>
+
+<h2><a name="locking">Locking policies</a></h2>
+
+<p>
+<i>Locking policies</i> describe a mutex type and an associated
+scoped lock type.
+flyweight uses a given locking
+policy to synchronize the access to its internal
+factory.
+</p>
+
+<p>
+A type <code>Locking</code> is a locking policy if:
+<ul>
+ <li>One of the following conditions is satisfied:
+ <ol type="a">
+ <li>is_locking<Locking>::type is
+ boost::mpl::true_,</li>
+ <li><code>Locking</code> is of the form
+ locking<Locking'>.</li>
+ </ol>
+ </li>
+ <li>The type <code>Locking::mutex_type</code> (or
+ <code>Locking'::mutex_type</code> if (b) applies) is a
+ model of Mutex
+ and supports recursive locking.
+ </li>
+ <li>The type <code>Locking::lock_type</code> (or
+ <code>Locking'::lock_type</code> if (b) applies) is a
+ Scoped Lock of
+ the mutex referred to above.
+ </li>
+</ul>
+</p>
+
+<h2><a name="locking_tag_synopsis">Header
+"boost/flyweight/locking_tag.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>locking_marker</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>is_locking</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>locking</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<h3><a name="is_locking">Class template <code>is_locking</code></h3>
+
+<p>
+Unless specialized by the user, <code>is_locking&lt;T&gt;::type</code> is
+boost::mpl::true_
+if <code>T</code> is derived from <code>locking_marker</code>, and it is
+boost::mpl::false_
+otherwise.
+</p>
+
+<h3><a name="locking_construct">Class template <code>locking</code></h3>
+
+<p>
+<code>locking&lt;T&gt;</code> is a syntactic construct meant to indicate
+that <code>T</code> is a locking policy without resorting to the
+mechanisms provided by the <code>is_locking</code> class template.
+</p>
+
+<h2><a name="simple_locking_fwd_synopsis">Header
+"boost/flyweight/simple_locking_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>simple_locking</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>simple_locking_fwd.hpp</code> forward declares the class
+simple_locking.
+</p>
+
+<h2><a name="simple_locking_synopsis">Header
+"boost/flyweight/simple_locking.hpp" synopsis</a></h2>
+
+<h3><a name="simple_locking">Class <code>simple_locking</code></a></h3>
+
+<p>
+Locking Policy that specifies a basic
+mutex type based on the simplest synchronization mechanisms provided by
+the environment; When no threading capabilities are available,
+<code>no_locking</code> specifies a dummy type without actual
+synchronization capabilities.
+</p>
+
+<h2><a name="no_locking_fwd_synopsis">Header
+"boost/flyweight/no_locking_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>no_locking</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>no_locking_fwd.hpp</code> forward declares the class
+no_locking.
+</p>
+
+<h2><a name="no_locking_synopsis">Header
+"boost/flyweight/no_locking.hpp" synopsis</a></h2>
+
+<h3><a name="no_locking">Class <code>no_locking</code></a></h3>
+
+<p>
+Null Locking Policy: it specifies a dummy
+type that satisfies the formal requirements for the
+Mutex concept but does not perform
+thread blocking. <code>no_locking</code> should only be used in single-threaded
+environments.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="holders.html"><img src="../prev.gif" alt="holders" border="0"><br>
+Holders
+</a></div>
+<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="tracking.html"><img src="../next.gif" alt="tracking policies" border="0"><br>
+Tracking policies
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 26th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/reference/tags.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/tags.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<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="up" href="index.html">
+<link rel="next" href="factories.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" 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
+</a></div>
+<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="factories.html"><img src="../next.gif" alt="factories" border="0"><br>
+Factories
+</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>
+ <li>
Tags</li>
+ <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>
+ </ul>
+ </li>
+</ul>
+
+<h2><a name="tag">Tags</a></h2>
+
+<p>
+A <i>tag</i> is a type of the form
+tag<T> for some arbitrary
+<code>T</code>.
+In the context of Boost.Flyweight, tags are syntactic artifacts used
+to differentiate instantiations of the class template
+flyweight which would
+otherwise be identical. Tagging a <code>flyweight</code> instantiation with
+a tag type local to a given context ensures that the global resources
+of that instantiation (for instance, the associated
+factory class) will not be unintentionally
+shared by other areas of the program.
+</p>
+
+<h2><a name="tag_synopsis">Header
+"boost/flyweight/tag.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>tag</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<h3><a name="tag_construct">Class template <code>tag</code></h3>
+
+<p>
+For any type <code>T</code>, <code>tag&lt;T&gt;</code> is a suitable
+tag for use in instantiations of
+flyweight.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="flyweight.html"><img src="../prev.gif" alt="flyweight reference" border="0"><br>
+<code>flyweight</code> reference
+</a></div>
+<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="factories.html"><img src="../next.gif" alt="factories" border="0"><br>
+Factories
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised August 6th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/reference/tracking.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/reference/tracking.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,291 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Tracking policies reference</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="locking.html">
+<link rel="up" href="index.html">
+<link rel="next" href="xxx.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight
+Tracking policies reference</h1>
+
+<div class="prev_link"><a href="locking.html"><img src="../prev.gif" alt="locking policies" border="0"><br>
+Locking policies
+</a></div>
+<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="xxx.html"><img src="../next.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[more to come]</font>
+</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>
+ <li>
Preliminary concepts</li>
+ <li>Tracking policies</li>
+ <li><a href="#tracking_tag_synopsis">Header
+ <code>"boost/flyweight/tracking_tag.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class template is_tracking</li>
+ <li>Class template tracking</li>
+ </ul>
+ </li>
+ <li><a href="#refcounted_fwd_synopsis">Header
+ <code>"boost/flyweight/refcounted_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#refcounted_synopsis">Header
+ <code>"boost/flyweight/refcounted.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class refcounted</li>
+ </ul>
+ </li>
+ <li><a href="#no_tracking_fwd_synopsis">Header
+ <code>"boost/flyweight/no_tracking_fwd.hpp"</code> synopsis</a>
+ </li>
+ <li><a href="#no_tracking_synopsis">Header
+ <code>"boost/flyweight/no_tracking.hpp"</code> synopsis</a>
+ <ul>
+ <li>Class no_tracking</li>
+ </ul>
+ </li>
+</ul>
+
+<h2><a name="preliminary">Preliminary concepts</a></h2>
+
+<p>
+A <i>tracking policy helper</i> provides access to some of the functionality
+of a factory so as to be used
+in the implementation of an associated Tracking Policy.
+In the following table, <code>TrackingHelper</code> is a tracking policy
+helper associated to a factory type
+<code>Factory</code> of elements of type <code>Entry</code>, <code>h</code>
+is a value of
+<code>Factory::handle_type</code> associated to a <code>Factory</code> <code>f</code>
+and <code>check</code> is a value of
+a Predicate
+type <code>Checker</code> with argument of type <code>Factory::handle_type</code>.
+</p>
+
+<p align="center">
+<table cellspacing="0">
+ <caption><b>Tracking Policy Helper requirements.</b></caption>
+<tr>
+ <th align="center">expression</th>
+ <th align="center">return type</th>
+ <th align="center">assertion/note<br>pre/post-condition</th>
+</tr>
+<tr>
+ <td><code>TrackingHelper::entry(h);</code></td>
+ <td><code>const Entry&</code></td>
+ <td>Returns <code>f.entry(h)</code>.</td>
+</tr>
+<tr class="odd_tr">
+ <td><code>TrackingHelper::erase(h,check);</code></td>
+ <td><code>void</code></td>
+ <td>If <code>check(h)</code>, invokes <code>f.erase(h)</code>.</td>
+</tr>
+</table>
+</p>
+
+<p>
+The execution of <code>TrackingHelper::erase</code> (including the
+invocation of <code>check(h)</code>) is done in a
+synchronized manner so as to prevent any other thread of execution from
+simultaneously accessing the factory's insertion or deletion facilities.
+</p>
+
+<h2><a name="tracking">Tracking policies</a></h2>
+
+<p>
+A <i>tracking policy</i> defines the strategy to be followed by a
+flyweight instantiation when
+all the flyweight objects associated to a given value are destroyed.
+The tracking policy contributes some type information necessary for the
+definition of the <code>flyweight</code> internal
+factory.
+</p>
+
+<p>
+A type <code>Tracking</code> is a tracking policy if:
+<ul>
+ <li>One of the following conditions is satisfied:
+ <ol type="a">
+ <li>is_tracking<Tracking>::type is
+ boost::mpl::true_,</li>
+ <li><code>Tracking</code> is of the form
+ tracking<Tracking'>.</li>
+ </ol>
+ </li>
+ <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
+ Assignable
+ type <code>Entry</code> implicitly convertible to <code>const Value&amp;</code>.
+ </li>
+ <li>The expression <code>Tracking::handle_type</code> (or
+ <code>Tracking'::handle_type</code> if (b) applies) is an
+ <a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
+ Expression</code></a>; this expression, when invoked with types
+ (<code>InternalHandle</code>,TrackingHelper),
+ with <code>InternalHandle</code> being
+ Assignable
+ and providing the nothrow guarantee for copy and assignment,
+ resolves to an
+ Assignable
+ type <code>Handle</code> which also provides the nothrow guarantee for
+ copy and assignment and is constructible from and implicitly
+ convertible to <code>InternalHandle</code>.
+ <code>TrackingHelper</code> is an incomplete type at the time of
+ invocation of <code>Tracking::handle_type</code>.
+ </li>
+</ul>
+<code>Tracking::handle_type</code> is parameterized by a helper that provides
+access to some of the functionality of the factory associated to the
+tracking policy. This factory's associated entry and handle types are the types
+<code>Entry</code> and <code>Handle</code> defined above, respectively.
+</p>
+
+<h2><a name="tracking_tag_synopsis">Header
+"boost/flyweight/tracking_tag.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>tracking_marker</span><span class=special>;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>is_tracking</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
+<span class=keyword>struct</span> <span class=identifier>tracking</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<h3><a name="is_tracking">Class template <code>is_tracking</code></h3>
+
+<p>
+Unless specialized by the user, <code>is_tracking&lt;T&gt;::type</code> is
+boost::mpl::true_
+if <code>T</code> is derived from <code>tracking_marker</code>, and it is
+boost::mpl::false_
+otherwise.
+</p>
+
+<h3><a name="tracking_construct">Class template <code>tracking</code></h3>
+
+<p>
+<code>tracking&lt;T&gt;</code> is a syntactic construct meant to indicate
+that <code>T</code> is a tracking policy without resorting to the
+mechanisms provided by the <code>is_tracking</code> class template.
+</p>
+
+<h2><a name="refcounted_fwd_synopsis">Header
+"boost/flyweight/refcounted_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>refcounted</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>refcounted_fwd.hpp</code> forward declares the class
+refcounted.
+</p>
+
+<h2><a name="refcounted_synopsis">Header
+"boost/flyweight/refcounted.hpp" synopsis</a></h2>
+
+<h3><a name="refcounted">Class <code>refcounted</code></a></h3>
+
+<p>
+Tracking Policy providing
+flyweight
+instantiations with reference counting semantics: when all the flyweight objects
+associated to a given value are destroyed, the corresponding entry is
+erased from <code>flyweight</code>'s internal
+factory.
+</p>
+
+<h2><a name="no_tracking_fwd_synopsis">Header
+"boost/flyweight/no_tracking_fwd.hpp" synopsis</a></h2>
+
+<blockquote><pre>
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>struct</span> <span class=identifier>no_tracking</span><span class=special>;</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
+
+<span class=special>}</span> <span class=comment>// namespace boost</span>
+</pre></blockquote>
+
+<p>
+<code>no_tracking_fwd.hpp</code> forward declares the class
+no_tracking.
+</p>
+
+<h2><a name="no_tracking_synopsis">Header
+"boost/flyweight/no_tracking.hpp" synopsis</a></h2>
+
+<h3><a name="no_tracking">Class <code>no_tracking</code></a></h3>
+
+<p>
+Null Tracking Policy: elements inserted
+into <code>flyweight</code>'s internal factory
+are not erased until program termination.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="locking.html"><img src="../prev.gif" alt="locking policies" border="0"><br>
+Locking policies
+</a></div>
+<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="xxx.html"><img src="../next.gif" alt="xxx" border="0"><br>
+<font color="#ff0000">[more to come]</font>
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 26th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/style.css
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/style.css 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,54 @@
+/* Copyright 2003-2004 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)
+ */
+
+pre{
+ BORDER-RIGHT: gray 1pt solid;
+ PADDING-RIGHT: 2pt;
+ BORDER-TOP: gray 1pt solid;
+ DISPLAY: block;
+ PADDING-LEFT: 2pt;
+ PADDING-BOTTOM: 2pt;
+ BORDER-LEFT: gray 1pt solid;
+ MARGIN-RIGHT: 32pt;
+ PADDING-TOP: 2pt;
+ BORDER-BOTTOM: gray 1pt solid;
+ FONT-FAMILY: "Courier New", Courier, mono;
+ background-color: #EEEEEE;
+}
+
+table{
+ PADDING-RIGHT: 2pt;
+ BORDER-TOP: gray 1pt solid;
+ DISPLAY: block;
+ PADDING-LEFT: 2pt;
+ PADDING-BOTTOM: 2pt;
+ BORDER-LEFT: gray 1pt solid;
+ MARGIN-RIGHT: 32pt;
+ PADDING-TOP: 2pt;
+ background-color: #EEEEEE;
+}
+td{
+ BORDER-STYLE: solid;
+ BORDER-WIDTH: 1pt;
+ BORDER-LEFT: ;
+ BORDER-RIGHT: gray 1pt solid;
+ BORDER-TOP: ;
+ BORDER-BOTTOM: gray 1pt solid;
+}
+th{color: #ffffff; background-color: #000000;}
+.odd_tr{background-color: #ffffff;}
+
+.keyword{color: #0000FF;}
+.identifier{}
+.comment{font-style: italic; color: #008000;}
+.special{color: #800040;}
+.preprocessor{color: #3F007F;}
+.string{font-style: italic; color: #666666;}
+.literal{font-style: italic; color: #666666;}
+
+.prev_link{width: 30%; float: left; text-align: left;}
+.up_link{width: 39.9%; float: left; text-align: center;}
+.next_link{width: 30%; float: left; text-align: right;}

Added: sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/basics.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,273 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Tutorial - Basics</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="index.html">
+<link rel="up" href="index.html">
+<link rel="next" href="configuration.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" 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>
+Boost.Flyweight tutorial
+</a></div>
+<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
+</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>
+ <li>Introduction
+ <ul>
+ <li>Serialization</li>
+ </ul>
+ </li>
+ <li>Flyweight requirements</li>
+</ul>
+
+<h2><a name="intro">Introduction</a></h2>
+
+<p>
+Suppose we are writing a massive multiplayer online game
+which has to maintain hundreds of thousands or millions of instances
+of the following class in memory:
+</p>
+
+<blockquote><pre>
+<span class=keyword>struct</span> <span class=identifier>user_entry</span>
+<span class=special>{</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>first_name</span><span class=special>;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>last_name</span><span class=special>;</span>
+ <span class=keyword>int</span> <span class=identifier>age</span><span class=special>;</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+In this kind of environments memory resources are precious, so we are seeking
+ways to make <code>user_entry</code> as compact as possible. Typically, there
+exists a very high level of repetition of first and last names among
+the community users, so an obvious optimization consists in moving
+<code>user_entry::first_name</code> and <code>user_entry::last_name</code>
+objects to a common repository where duplicates are avoided, and leaving
+references to these inside <code>user_entry</code>. This is precisely what
+Boost.Flyweight does in the simplest possible way for the programmer:
+</p>
+
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=keyword>struct</span> <span class=identifier>user_entry</span>
+<span class=special>{</span>
+ <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>first_name</span><span class=special>;</span>
+ <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>last_name</span><span class=special>;</span>
+ <span class=keyword>int</span> <span class=identifier>age</span><span class=special>;</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+Boost.Flyweight automatically performs the optimization just described behind
+the scenes, so that the net effect of this change is that the memory
+usage of the program decreases by a factor proportional to the level of
+redundancy among user names.
+</p>
+
+<p>
+<code>flyweight&lt;std::string&gt;</code> behaves in many ways like
+<code>std::string</code>; for instance, the following code works
+unchanged after the redefinition of <code>user_entry</code>:
+</p>
+
+<blockquote><pre>
+<span class=comment>// flyweight&lt;T&gt; can be constructed in the same way as T objects can,
+// even with multiple argument constructors</span>
+
+<span class=identifier>user_entry</span><span class=special>::</span><span class=identifier>user_entry</span><span class=special>(</span><span class=keyword>const</span> <span class=keyword>char</span><span class=special>*</span> <span class=identifier>f</span><span class=special>,</span><span class=keyword>const</span> <span class=keyword>char</span><span class=special>*</span> <span class=identifier>l</span><span class=special>,</span><span class=keyword>int</span> <span class=identifier>a</span><span class=special>,...):</span>
+ <span class=identifier>first_name</span><span class=special>(</span><span class=identifier>f</span><span class=special>),</span>
+ <span class=identifier>last_name</span><span class=special>(</span><span class=identifier>l</span><span class=special>),</span>
+ <span class=identifier>age</span><span class=special>(</span><span class=identifier>a</span><span class=special>),</span>
+ <span class=special>...</span>
+<span class=special>{}</span>
+
+<span class=comment>// flyweight classes have relational operators replicating the
+// semantics of the underyling type</span>
+
+<span class=keyword>bool</span> <span class=identifier>same_name</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user1</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user2</span><span class=special>)</span>
+<span class=special>{</span>
+ <span class=keyword>return</span> <span class=identifier>user1</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>==</span><span class=identifier>user2</span><span class=special>.</span><span class=identifier>first_name</span> <span class=special>&amp;&amp;</span>
+ <span class=identifier>user1</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>==</span><span class=identifier>user2</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>;</span>
+<span class=special>}</span>
+
+<span class=comment>// flyweight&lt;T&gt; provides operator&lt;&lt; and operator&gt;&gt; internally
+// forwarding to T::operator&lt;&lt; and T::operator&gt;&gt;</span>
+
+<span class=identifier>std</span><span class=special>::</span><span class=identifier>ostream</span><span class=special>&amp;</span> <span class=keyword>operator</span><span class=special>&lt;&lt;(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>ostream</span><span class=special>&amp;</span> <span class=identifier>os</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user</span><span class=special>)</span>
+<span class=special>{</span>
+ <span class=keyword>return</span> <span class=identifier>os</span><span class=special>&lt;&lt;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>&lt;&lt;</span><span class=string>&quot; &quot;</span><span class=special>&lt;&lt;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>&lt;&lt;</span><span class=string>&quot; &quot;</span><span class=special>&lt;&lt;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>age</span><span class=special>;</span>
+<span class=special>}</span>
+
+<span class=identifier>std</span><span class=special>::</span><span class=identifier>istream</span><span class=special>&amp;</span> <span class=keyword>operator</span><span class=special>&gt;&gt;(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>istream</span><span class=special>&amp;</span> <span class=identifier>is</span><span class=special>,</span><span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user</span><span class=special>)</span>
+<span class=special>{</span>
+ <span class=keyword>return</span> <span class=identifier>is</span><span class=special>&gt;&gt;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>&gt;&gt;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>&gt;&gt;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>age</span><span class=special>;</span>
+<span class=special>}</span>
+</pre></blockquote>
+
+<p>
+Besides, <code>flyweight&lt;T&gt;</code> is convertible to
+<code>const T&amp;</code>, either implicitly or through the <code>get</code>
+member function:
+</p>
+
+<blockquote><pre>
+<span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>full_name</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user</span><span class=special>)</span>
+<span class=special>{</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span> <span class=identifier>full</span><span class=special>;</span>
+
+ <span class=identifier>full</span><span class=special>.</span><span class=identifier>reserve</span><span class=special>(</span>
+ <span class=identifier>user</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>.</span><span class=identifier>get</span><span class=special>().</span><span class=identifier>size</span><span class=special>()+</span> <span class=comment>// get() returns the underlying</span>
+ <span class=identifier>user</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>.</span><span class=identifier>get</span><span class=special>().</span><span class=identifier>size</span><span class=special>()+</span><span class=number>1</span><span class=special>);</span> <span class=comment>// const std::string&amp;</span>
+
+ <span class=identifier>full</span><span class=special>+=</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>;</span> <span class=comment>// implicit conversion is used here</span>
+ <span class=identifier>full</span><span class=special>+=</span><span class=string>&quot; &quot;</span><span class=special>;</span>
+ <span class=identifier>full</span><span class=special>+=</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>;</span>
+
+ <span class=keyword>return</span> <span class=identifier>full</span><span class=special>;</span>
+<span class=special>}</span>
+</pre></blockquote>
+
+<p>
+The most important restriction to take into account when replacing a class
+with an equivalent flyweight is the fact that flyweights are not
+mutable: since several flyweight objects can share the same representation
+value, modifying this value is not admissible. On the other hand, flyweight
+objects can be assigned new values:
+</p>
+
+<blockquote><pre>
+<span class=keyword>void</span> <span class=identifier>change_name</span><span class=special>(</span>
+ <span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user</span><span class=special>,</span>
+ <span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&amp;</span> <span class=identifier>f</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&amp;</span> <span class=identifier>l</span><span class=special>)</span>
+<span class=special>{</span>
+ <span class=identifier>user</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>=</span><span class=identifier>f</span><span class=special>;</span>
+ <span class=identifier>user</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>=</span><span class=identifier>l</span><span class=special>;</span>
+<span class=special>}</span>
+</pre></blockquote>
+
+<p>
+In general, <code>flyweight&lt;T&gt;</code> interface is designed to make
+the transition from plain <code>T</code> as straightforward as possible.
+Check the reference for
+further details on the interface of the class template <code>flyweight</code>.
+The examples section explores
+some common usage scenarios of Boost.Flyweight.
+</p>
+
+<h4><a name="serialization">Serialization</a></h4>
+
+<p>
+<code>flyweight&lt;T&gt;</code> can be serialized by means of the
+Boost Serialization Library
+as long as the underlying <code>T</code> is serializable. Both regular and
+XML archives are supported. In order to
+use Boost.Flyweight serialization capabilities, the specific
+header "boost/flyweight/serialize.hpp"
+must be included.
+</p>
+
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>serialize</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>class</span> <span class=identifier>Archive</span><span class=special>&gt;</span>
+<span class=keyword>void</span> <span class=identifier>serialize</span><span class=special>(</span><span class=identifier>Archive</span><span class=special>&amp;</span> <span class=identifier>ar</span><span class=special>,</span><span class=identifier>user_entry</span><span class=special>&amp;</span> <span class=identifier>user</span><span class=special>,</span><span class=keyword>const</span> <span class=keyword>unsigned</span> <span class=keyword>int</span><span class=special>)</span>
+<span class=special>{</span>
+ <span class=identifier>ar</span><span class=special>&amp;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>first_name</span><span class=special>;</span>
+ <span class=identifier>ar</span><span class=special>&amp;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>last_name</span><span class=special>;</span>
+ <span class=identifier>ar</span><span class=special>&amp;</span><span class=identifier>user</span><span class=special>.</span><span class=identifier>age</span><span class=special>;</span>
+ <span class=special>...</span>
+<span class=special>}</span>
+</pre></blockquote>
+
+<p>
+Much as using Boost.Flyweight reduces memory consumption due to the internal
+sharing of duplicate values, serializing <code>flyweight</code>s can also
+result in smaller archive files, as a common value is only stored
+once and their associated <code>flyweight</code>s get saved as references to it.
+This policy is observed even if <code>flyweight</code> underlying type is
+not tracked
+by Boost.Serialization.
+</p>
+
+<p>
+See example 4 at the examples section
+for an illustration of use of Boost.Flyweight serialization capabilities.
+</p>
+
+<h3><a name="requirements">Flyweight requirements</a></h3>
+
+<p>
+For <code>flyweight&lt;T&gt;</code> to be instantiable, <code>T</code> must
+be Assignable,
+<a href="http://www.sgi.com/tech/stl/EqualityComparable.html"><code>Equality
+Comparable</code></a> and must interoperate with
+Boost.Hash.
+The first requirement is probably met without any extra effort by the user,
+not so the other two, except for the most common basic types of C++
+and the standard library. Equality and hashing of <code>T</code> are used
+internally by <code>flyweight&lt;T&gt;</code> internal factory to maintain the
+common repository of unique <code>T</code> values referred to by the flyweight
+objects. Consult the Boost.Hash documentation
+section on extending
+that library for custom data types.
+</p>
+
+<p>
+As we have seen, equality and hash requirements on <code>T</code> are
+imposed by the particular type of <i>flyweight factory</i> internally used by
+<code>flyweight&lt;T&gt;</code>. We will see later how the user can customize
+this factory to use equality and hash predicates other than the default,
+or even switch to an entirely different kind of factory which may impose
+another requirements on <code>T</code>, as described in the section on
+configuring Boost.Flyweight.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="index.html"><img src="../prev.gif" alt="Boost.Flyweight tutorial" border="0"><br>
+Boost.Flyweight tutorial
+</a></div>
+<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
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised November 12th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/configuration.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,580 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<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="up" href="index.html">
+<link rel="next" href="extension.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" 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
+</a></div>
+<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="extension.html"><img src="../next.gif" alt="extending Boost.Flyweight" border="0"><br>
+Extending Boost.Flyweight
+</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>
+ <li>
Configurable aspects of Boost.Flyweight
+ <ul>
+ <li>Free-order template parameter interface</li>
+ <li>Header inclusion</li>
+ </ul>
+ </li>
+ <li>Tagging</li>
+ <li>Factory specification
+ <ul>
+ <li>hashed_factory</li>
+ <li>set_factory</li>
+ <li>assoc_container_factory</li>
+ </ul>
+ </li>
+ <li>Holder specification
+ <ul>
+ <li>static_holder</li>
+ <li>intermodule_holder</li>
+ </ul>
+ </li>
+ <li>Locking policies
+ <ul>
+ <li>simple_locking</li>
+ <li>no_locking</li>
+ </ul>
+ </li>
+ <li>Tracking policies
+ <ul>
+ <li>refcounted</li>
+ <li>no_tracking</li>
+ </ul>
+ </li>
+</ul>
+
+<h2><a name="intro">Configurable aspects of Boost.Flyweight</a></h2>
+
+<p>
+Most of the time, <code>flyweight</code> default configuration is just good
+enough and the user need not care about further tuning of her <code>flyweight</code>
+instantiations; however, when the necessity for more control over Boost.Flyweight
+behavior arises, comprehensive mechanisms are provided to select, configure and
+even extend the following implementation aspects:
+<ul>
+ <li>Type tagging.</li>
+ <li>Factory used to store the shared values
+ <code>flyweight</code> objects refer to.
+ </li>
+ <li>Mechanism of instantiation of the flyweight factory.</li>
+ <li>Internal synchronization mecanism 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
+ destroyed.
+ </li>
+</ul>
+</p>
+
+<h3><a name="free_order_template">Free-order template parameter interface</a></h3>
+
+<p>
+The <code>flyweight</code> class template features a "smart" specification
+interface by which the configuration aspects can be provided as optional template arguments
+in whatever order the user pleases. For instance, a tagged <code>flyweight</code>
+of <code>std::string</code>s with a set-based factory and
+no tracking can be specified in any of
+the following manners:
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>label_t</span><span class=special>&gt;,</span> <span class=identifier>set_factory</span><span class=special>&lt;&gt;,</span> <span class=identifier>no_tracking</span> <span class=special>&gt;</span>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>label_t</span><span class=special>&gt;,</span> <span class=identifier>no_tracking</span><span class=special>,</span> <span class=identifier>set_factory</span><span class=special>&lt;&gt;</span> <span class=special>&gt;</span>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=identifier>set_factory</span><span class=special>&lt;&gt;,</span> <span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>label_t</span><span class=special>&gt;,</span> <span class=identifier>no_tracking</span> <span class=special>&gt;</span>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=identifier>set_factory</span><span class=special>&lt;&gt;,</span> <span class=identifier>no_tracking</span><span class=special>,</span> <span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>label_t</span><span class=special>&gt;</span> <span class=special>&gt;</span>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=identifier>no_tracking</span><span class=special>,</span> <span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>label_t</span><span class=special>&gt;,</span> <span class=identifier>set_factory</span><span class=special>&lt;&gt;</span> <span class=special>&gt;</span>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span> <span class=identifier>no_tracking</span><span class=special>,</span> <span class=identifier>set_factory</span><span class=special>&lt;&gt;,</span> <span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>label_t</span><span class=special>&gt;</span> <span class=special>&gt;</span>
+</pre></blockquote>
+
+<h3><a name="header_inclusion">Header inclusion</a></h3>
+
+<p>
+The example code shown at the introductory section
+uses the
+"boost/flyweight.hpp"
+convenience header, which simply includes the headers for the class template
+<code>flyweight</code> and its default configuration components:
+</p>
+
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span> <span class=comment>// class template flyweight</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>hashed_factory</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span> <span class=comment>// hashed flyweight factory</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>static_holder</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span> <span class=comment>// regular factory instantiation</span>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>refcounted</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span> <span class=comment>// refcounting tracking policy</span>
+</pre></blockquote>
+
+<p>
+When using components other than these, their specific headers must be
+explicitly included.
+</p>
+
+<h2><a name="tagging">Tagging</a></h2>
+
+<p>
+Consider the following two types:
+</p>
+
+<blockquote><pre>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>name_t</span><span class=special>;</span>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>ip_address_t</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+Although technically both types are identical, this is so by virtue of
+coincidence, as there is no sensible relation between names and IP addresses.
+Internally, the fact that <code>name_t</code> and <code>ip_address_t</code>
+are the same flyweight type causes values of both classes to be stored together
+in the same flyweight factory, although their respective ranges
+are not expected to overlap. <i>Tagging</i> can be used to turn these
+into really different types:
+</p>
+
+<blockquote><pre>
+<span class=keyword>struct</span> <span class=identifier>name_tag</span><span class=special>{};</span>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span><span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>name_tag</span><span class=special>&gt;</span> <span class=special>&gt;</span> <span class=identifier>name_t</span><span class=special>;</span>
+
+<span class=keyword>struct</span> <span class=identifier>ip_address_tag</span><span class=special>{};</span>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span><span class=identifier>tag</span><span class=special>&lt;</span><span class=identifier>ip_address_tag</span><span class=special>&gt;</span> <span class=special>&gt;</span> <span class=identifier>ip_address_t</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+Now, <code>name_t</code> and <code>ip_address_t</code> are different
+flyweight classes having separate factories each. Tags are a purely syntactic
+device: any type can be used for tagging inside the <code>tag</code>
+construct, though good style recommends using tag classes with
+descriptive names which are local to the context where the flyweight type
+is being defined.
+</p>
+
+<h2><a name="factories">Factory specification</a></h2>
+
+<p>
+<code>flyweight</code> uses a type of internal component called
+<i>factory</i> whose purpose is to store and retrieve the different values
+flyweight objects refer to at a given time. By default, a factory based on
+a hashed container is used, so that <code>flyweight&lt;T&gt;</code> is
+actually equivalent to
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>hashed_factory</span><span class=special>&lt;&gt;</span> <span class=special>&gt;</span>
+</pre></blockquote>
+
+<p>
+where <code>hashed_factory</code> is a so-called <i>factory specifier</i>.
+Boost.Flyweight provides several predefined factory specifiers, which not
+only let the user select the specific type of factory used, but also
+accept their own template arguments to customize each factory.
+</p>
+
+<h3><a name="hashed_factory"><code>hashed_factory</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/hashed_factory.hpp"<br>
+<b>Syntax:</b> <code>hashed_factory&lt;[Hash[,Pred[,Allocator]]]&gt;</code>
+</blockquote>
+
+<p>
+This specifier, which Boost.Flyweight takes by default, controls the usage of a
+factory internally based in a hash container. Values are determined to be
+equivalent by means of the
+<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html"><code>Binary
+Predicate</code></a> <code>Pred</code>, and indexed into the factory container
+using <code>Hash</code>, which is assumed to be a <i>hash function</i>,
+i.e. a
+<a href="http://www.sgi.com/tech/stl/UnaryFunction.html"><code>Unary
+Function</code></a> assigning to each value a hash identifier of
+type <code>std::size_t</code>. The <code>Allocator</code> parameter is
+used by the factory container for its memory allocation needs. The default
+types for these parameters are such that the expression
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>hashed_factory</span><span class=special>&lt;&gt;</span> <span class=special>&gt;</span>
+</pre></blockquote>
+
+<p>
+is equivalent to
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>T</span><span class=special>,</span>
+ <span class=identifier>hashed_factory</span><span class=special>&lt;</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>hash</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>equal_to</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
+<span class=special>&gt;</span>
+</pre></blockquote>
+
+<h3><a name="set_factory"><code>set_factory</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/set_factory.hpp"<br>
+<b>Syntax:</b> <code>set_factory&lt;[Compare[,Allocator]]&gt;</code>
+</blockquote>
+
+<p>
+<code>set_factory</code> resorts to an <code>std::set</code>-like ordered
+container for the implementation of the flyweight factory.
+<code>Compare</code> must be a
+<a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html"><code>Strict
+Weak Ordering</code></a> on the value type <code>flyweight</code> is
+acting upon; as is customary with STL ordered containers, two values
+are considered equivalent if none is less than the other according to <code>Pred</code>.
+<code>Allocator</code> is an allocator type passed along to the factory
+internal container for its memory-related tasks. When default parameters are
+used, the expression
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>,</span><span class=identifier>set_factory</span><span class=special>&lt;&gt;</span> <span class=special>&gt;</span>
+</pre></blockquote>
+
+<p>
+is equivalent to
+</p>
+
+<blockquote><pre>
+<span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>T</span><span class=special>,</span>
+ <span class=identifier>set_factory</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;,</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
+<span class=special>&gt;</span>
+</pre></blockquote>
+
+<p>
+Usual tradeoffs arising in the comparison of ordered and hashed containers
+also apply when choosing between <code>set_factory</code> and
+<code>hashed_factory</code>:
+so, set-based lookup and insertion of values are generally slower than those based on hashing,
+but the latter can be affected by pathological worst-case scenarios with very
+poor performance.
+</p>
+
+<h3><a name="assoc_container_factory"><code>assoc_container_factory</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/assoc_container_factory.hpp"<br>
+<b>Syntax:</b> <code>assoc_container_factory&lt;ContainerSpecifier&gt;</code>
+</blockquote>
+
+<p>
+This specifier can be seen as a generalization of
+<code>hashed_factory</code> and <code>set_factory</code> where the user
+supplies the exact type of container on which the factory is based.
+The way in which the container is specified might seem at first a little
+daunting to those unfamiliar with the
+Boost MPL Library:
+<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&amp;</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
+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>.
+ </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
+ many existing implementations of hashed containers that invalidate iterators
+ upon a rehashing operation.
+ </li>
+</ol>
+</p>
+
+<p>
+Let us see what a container specifier looks like with an example.
+Suppose we have our own ordered container like the following:
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</span>
+ <span class=keyword>typename</span> <span class=identifier>Elem</span><span class=special>,</span>
+ <span class=keyword>typename</span> <span class=identifier>Compare</span><span class=special>=</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>less</span><span class=special>&lt;</span><span class=identifier>Elem</span><span class=special>&gt;,</span>
+ <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>=</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special>&lt;</span><span class=identifier>Elem</span><span class=special>&gt;</span>
+<span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>ultrafast_set</span>
+<span class=special>{</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+Then <code>ultrafast_set</code> can be plugged into
+<code>assoc_container_factory</code> like this:
+</p>
+
+<blockquote><pre>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier>assoc_container_factory</span><span class=special>&lt;</span>
+ <span class=comment>// MPL lambda expression follows</span>
+ <b><span class=identifier>ultrafast_set</span><span class=special>&lt;</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>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=special>&gt;</span></b>
+ <span class=special>&gt;</span>
+<span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</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
+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&amp;</code>
+(here <code>const std::string&amp;</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,
+the default argument for the <code>Allocator</code> parameter works
+just fine, as is more apparent if we write it down explicitly:
+</p>
+
+<blockquote><pre>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier>assoc_container_factory</span><span class=special>&lt;</span>
+ <b><span class=identifier>ultrafast_set</span><span class=special>&lt;</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>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;,</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>allocator</span><span class=special>&lt;</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>&gt;</span>
+ <span class=special>&gt;</span>
+ <span class=special>&gt;</span></b>
+<span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</pre></blockquote>
+
+<h2><a name="holders">Holder specification</a></h2>
+
+<p>
+Each flyweight type, that is, each distinct instantiation of the class
+template <code>flyweight</code>, is associated with exactly one factory
+object. In most cases, how this factory object is created is of little
+importance to the user of Boost.Flyweight, but there are special
+circumstances where control of this aspect is necessary. An internal
+component called <i>holder</i> is in charge of instantiating the
+factory class and some other internal information; this component is
+stipulated by means of a <i>holder specifier</i>, <code>static_holder</code>
+being the default one.
+</p>
+
+<h3><a name="static_holder"><code>static_holder</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/static_holder.hpp"<br>
+<b>Syntax:</b> <code>static_holder</code>
+</blockquote>
+
+<p>
+This the default holder specifier of Boost.Flyweight, and produces
+holders where the unique factory lives as a local static variable of the
+program.
+</p>
+
+<h3><a name="intermodule_holder"><code>intermodule_holder</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/intermodule_holder.hpp"<br>
+<b>Syntax:</b> <code>intermodule_holder</code>
+</blockquote>
+
+<p>
+In most C++ environments, static variables do not mix well with
+dynamically loaded modules in the sense that instances of the same
+static variable can be duplicated across different modules, even
+though by definition the variable should be unique. In many
+cases, this duplication goes unnoticed if the modules do not communicate
+between each other using the affected types, but consider this
+case where such communication does happen:
+</p>
+
+<blockquote><pre>
+<span class=comment>// module 1</span>
+
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+
+<span class=comment>// produce_string is exported so that it can be dynamically
+// linked</span>
+
+<span class=identifier>flyweight_string</span> <span class=identifier>produce_string</span><span class=special>()</span>
+<span class=special>{</span>
+ <span class=keyword>return</span> <span class=identifier>flyweight_string</span><span class=special>(</span><span class=string>&quot;boost&quot;</span><span class=special>);</span>
+<span class=special>}</span>
+</pre></blockquote>
+
+<blockquote><pre>
+<span class=comment>// main program</span>
+
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt;</span> <span class=identifier>flyweight_string</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=comment>// import module 1</span>
+
+ <span class=identifier>flyweight_string</span> <span class=identifier>str1</span><span class=special>=</span><span class=identifier>produce_string</span><span class=special>();</span>
+ <span class=identifier>flyweight_string</span> <span class=identifier>str2</span><span class=special>(</span><span class=string>&quot;boost&quot;</span><span class=special>);</span>
+ <span class=identifier>assert</span><span class=special>(</span><span class=identifier>str1</span><span class=special>==</span><span class=identifier>str2</span><span class=special>);</span>
+<span class=special>}</span>
+</pre></blockquote>
+
+<p>
+In many environments, this program results in an assertion
+failure because the flyweight factory object used
+by <code>flyweight_string</code> as seen within module 1 is
+not the same factory object as seen within the main program: hence
+the value representations internally pointed to by <code>str1</code>
+and <code>str2</code> will differ and will be mistakenly
+considered as not equal. Many other problems might arise
+due to factory duplication, including undefined behavior.
+</p>
+
+<p>
+<code>intermodule_holder</code> specifies a factory holder which
+is capable of avoiding the duplication problem and ensuring that
+all modules of a program are using the same factory instance.
+To fix the example above, it suffices to redefine
+<code>flyweight_string</code> in both modules as:
+</p>
+
+<blockquote><pre>
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</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>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</pre></blockquote>
+
+
+<h2><a name="locking">Locking policies</a></h2>
+
+<p>
+The internal factory associated to each <code>flyweight</code>
+type is a shared resource and as such access to it must be properly
+synchronized in multithreaded environments. A <i>locking policy</i>
+specifies the synchronization mechanisms to be used for this purpose.
+</p>
+
+<h3><a name="simple_locking"><code>simple_locking</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/simple_locking.hpp"<br>
+<b>Syntax:</b> <code>simple_locking</code>
+</blockquote>
+
+<p>
+This is the default locking policy. It specifies the simplest native
+synchronization primitives provided by the operating system, whenever
+available.
+</p>
+
+<h3><a name="no_locking"><code>no_locking</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/no_locking.hpp"<br>
+<b>Syntax:</b> <code>no_locking</code>
+</blockquote>
+
+<p>
+No synchronization is enforced so that irrestricted internal access
+to the implementation shared resources is allowed.
+Selecting <code>no_locking</code> results in somewhat faster execution than
+the default <code>simple_locking</code>, but it renders the type
+thread-unsafe, which can have catastrophic consequences.
+This policy should not be used except in single-threaded environments or
+when there is an absolute guarantee that the particular <code>flyweight</code>
+type will not be used in a concurrent scenario.
+</p>
+
+<h2><a name="tracking">Tracking policies</a></h2>
+
+<p>
+A <i>tracking policy</i> controls the lifetimes of the <code>flyweight</code>
+objects and can act based on this information. For instance, a suitable
+tracking mechanism can determine when a given value stored in the factory
+can be safely erased because it is no longer referenced by any
+<code>flyweight</code>; this is precisely what the default tracking policy,
+<code>refcounted</code>, does.
+</p>
+
+<h3><a name="refcounted"><code>refcounted</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/refcounted.hpp"<br>
+<b>Syntax:</b> <code>refcounted</code>
+</blockquote>
+
+<p>
+This tracking policy determines that values stored in the factory be
+equipped with reference counting mechanisms so that a factory entry is
+erased when the last <code>flyweight</code> object associated to it
+is destroyed.
+</p>
+
+<h3><a name="no_tracking"><code>no_tracking</code></a></h3>
+
+<blockquote>
+<b>Header:</b> "boost/flyweight/no_tracking.hpp"<br>
+<b>Syntax:</b> <code>no_tracking</code>
+</blockquote>
+
+<p>
+No flyweight tracking is done when this policy is selected, which implies
+that the values stored in the factory remain in it until program termination.
+In comparison with <code>refcounted</code>, <code>no_tracking</code>
+produces flyweight objects which are faster to pass
+around and it also results in some reduction in memory usage due to the
+absence of reference counters. The most obvious drawback is that
+the number of unused entries stored in the factory can keep growing
+during the program lifetime, which can become a problem for certain
+patterns of flyweight creation where the set of active values "drifts"
+over time. Another drawback is a potential delay during program
+termination, since it is then when all the factory entries get destroyed
+at once.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="basics.html"><img src="../prev.gif" alt="basics" border="0"><br>
+Basics
+</a></div>
+<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="extension.html"><img src="../next.gif" alt="extending Boost.Flyweight" border="0"><br>
+Extending Boost.Flyweight
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised August 16th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/extension.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,475 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Tutorial - Extending Boost.Flyweight</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="configuration.html">
+<link rel="up" href="index.html">
+<link rel="next" href="lambda_expressions.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" 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>
+Configuring Boost.Flyweight
+</a></div>
+<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="lambda_expressions.html"><img src="../next.gif" alt="annex: MPL lambda expressions" border="0"><br>
+Annex: MPL lambda expressions
+</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>
+ <li>
Introduction</li>
+ <li>Custom factories</li>
+ <li>Custom holders</li>
+ <li>Custom locking policies</li>
+ <li>Custom tracking policies</li>
+</ul>
+
+<h2><a name="intro">Introduction</a></h2>
+
+<p>
+Boost.Flyweight provides public interface specifications of
+its configurable aspects so that the user
+can extend the library by implementing her own components and providing them to
+instantiations of the <code>flyweight</code> class template.
+</p>
+
+<p>
+In most cases there are two types of entities involved in extending a given
+aspect of Boost.Flyweight:
+<ul>
+ <li>The component itself (for instance, a factory class template).</li>
+ <li>The associated <i>component specifier</i>, which is the type
+ provided as a template argument of a <code>flyweight</code>
+ instantiation.
+ </li>
+</ul>
+For example, the type
+static_holder
+is a holder specifier which is used by <code>flyweight</code> to generate
+actual holder classes, in this case instantiations of the class
+template
+static_holder_class.
+Note that <code>static_holder</code> is a concrete type while
+<code>static_holder_class</code> is a class template, so a specifier can be
+seen as a convenient way to provide access to a family of related concrete
+components (the different possible instantiations of the class template):
+<code>flyweight</code> internally selects the concrete component
+appropriate for its internal types.
+</p>
+
+<h2><a name="factories">Custom factories</a></h2>
+
+<p>
+In a way, factories resemble unique associative containers like <code>std::set</code>,
+though their expected interface is much more concise:
+</p>
+
+<blockquote><pre>
+<span class=comment>// example of a possible factory class template</span>
+
+<span class=keyword>template</span><span class=special>&lt;</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>&gt;</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>
+ <span class=keyword>typedef</span> <span class=special>...</span> <span class=identifier>handle_type</span><span class=special>;</span>
+
+ <span class=identifier>handle_type</span> <span class=identifier>insert</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>Entry</span><span class=special>&amp;</span> <span class=identifier>x</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=keyword>const</span> <span class=identifier>Entry</span><span class=special>&amp;</span> <span class=identifier>entry</span><span class=special>(</span><span class=identifier>handle_type</span> <span class=identifier>h</span><span class=special>);</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+Factories are parameterized by <code>Entry</code> and <code>Value</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&lt;std::string&gt;</code>). An entry holds a member of type
+<code>Value</code> 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
+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
+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
+<code>erase()</code> and <code>entry()</code>. Consult the
+reference for the formal
+definition of the <code>Factory</code> concept.
+</p>
+
+<p>
+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:
+</p>
+
+<blockquote><pre>
+<span class=comment>// Factory specifier (metafunction class version)</span>
+
+<span class=keyword>struct</span> <span class=identifier>custom_factory_specifier</span>
+<span class=special>{</span>
+ <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>&gt;</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>&lt;</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>&gt;</span> <span class=identifier>type</span><span class=special>;</span>
+ <span class=special>}</span>
+<span class=special>};</span>
+
+<span class=comment>// Factory specifier (placeholder version)</span>
+
+<span class=keyword>typedef</span> <span class=identifier>custom_factory_class</span><span class=special>&lt;</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>&gt;</span> <span class=identifier>custom_factory_specifier</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+There is one last detail: in order to implement <code>flyweight</code>
+<a href="configuration.html#free_order_template">free-order template
+parameter interface</a>, it is necessary to explicitly tag a
+factory specifier as such, so that it can be distinguised from other
+types of specifiers. Boost.Flyweight provides three different mechanisms
+to do this tagging:
+<ol>
+ <li>Have the specifier derive from the dummy type <code>factory_marker</code>.
+ Note that this mechanism cannot be used with placeholder expressions.
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>factory_tag</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<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>&lt;</span><span class=keyword>typename</span> <span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>&gt;</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>&lt;</span><span class=identifier>Entry</span><span class=special>,</span><span class=identifier>Value</span><span class=special>&gt;</span> <span class=identifier>type</span><span class=special>;</span>
+ <span class=special>}</span>
+<span class=special>};</span>
+</pre></blockquote>
+ </li>
+ <li>Specialize a special class template called
+ is_factory:
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>factory_tag</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=keyword>struct</span> <span class=identifier>custom_factory_specifier</span><span class=special>{};</span>
+
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;&gt;</span> <span class=keyword>struct</span> <span class=identifier>is_factory</span><span class=special>&lt;</span><span class=identifier>custom_factory_specifier</span><span class=special>&gt;:</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>true_</span><span class=special>{};</span>
+
+<span class=special>}</span>
+<span class=special>}</span>
+</pre></blockquote>
+ </li>
+ <li>The third mechanism, which is the least intrusive, consists in
+ wrapping the specifier inside the
+ factory
+ construct:
+<blockquote><pre>
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>factory_tag</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier><b>factory</b></span><span class=special>&lt;</span><span class=identifier>custom_factory_specifier</span><span class=special>&gt;</span>
+<span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</pre></blockquote>
+ </li>
+</ol>
+</p>
+
+<h2><a name="holders">Custom holders</a></h2>
+
+<p>
+A holder is a class with a static member function <code>get()</code> giving
+access to a unique instance of a given type <code>C</code>:
+</p>
+
+<blockquote><pre>
+<span class=comment>// example of a possible holder class template</span>
+
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>C</span><span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>custom_holder_class</span>
+<span class=special>{</span>
+<span class=keyword>public</span><span class=special>:</span>
+ <span class=keyword>static</span> <span class=identifier>C</span><span class=special>&amp;</span> <span class=identifier>get</span><span class=special>();</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+<code>flyweight</code> internally uses a holder to create its associated
+factory as well as some other global data. A holder specifier is a
+<a href="lambda_expressions.html"><code>Lambda
+Expression</code></a> accepting the type <code>C</code> upon which
+the associated holder class operates:
+</p>
+
+<blockquote><pre>
+<span class=comment>// Holder specifier (metafunction class version)</span>
+
+<span class=keyword>struct</span> <span class=identifier>custom_holder_specifier</span>
+<span class=special>{</span>
+ <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>C</span><span class=special>&gt;</span>
+ <span class=keyword>struct</span> <span class=identifier>apply</span>
+ <span class=special>{</span>
+ <span class=keyword>typedef</span> <span class=identifier>custom_holder_class</span><span class=special>&lt;</span><span class=identifier>C</span><span class=special>&gt;</span> <span class=identifier>type</span><span class=special>;</span>
+ <span class=special>}</span>
+<span class=special>};</span>
+
+<span class=comment>// Holder specifier (placeholder version)</span>
+
+<span class=keyword>typedef</span> <span class=identifier>custom_holder_class</span><span class=special>&lt;</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>&gt;</span> <span class=identifier>custom_factory_specifier</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+As is the case with factory specifiers, holder
+specifiers must be tagged in order to be properly recognized when
+provided to <code>flyweight</code>, and there are three available mechanisms
+to do so:
+</p>
+
+<blockquote><pre>
+<span class=comment>// Alternatives for tagging a holder specifier</span>
+
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>holder_tag</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=comment>// 1: Have the specifier derive from holder_marker</span>
+
+<span class=keyword>struct</span> <span class=identifier>custom_holder_specifier</span><span class=special>:</span> <span class=identifier><b>holder_marker</b></span>
+<span class=special>{</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+
+<span class=comment>// 2: Specialize the is_holder class template</span>
+
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;&gt;</span> <span class=keyword>struct</span> <span class=identifier>is_holder</span><span class=special>&lt;</span><span class=identifier>custom_holder_specifier</span><span class=special>&gt;:</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>true_</span><span class=special>{};</span>
+
+<span class=special>}}</span>
+
+<span class=comment>// 3: use the holder&lt;&gt; wrapper when passing the specifier
+// to flyweight</span>
+
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier><b>holder</b></span><span class=special>&lt;</span><span class=identifier>custom_holder_specifier</span><span class=special>&gt;</span>
+<span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</pre></blockquote>
+
+<h2><a name="locking">Custom locking policies</a></h2>
+
+<p>
+A custom locking policy presents the following simple interface:
+</p>
+
+<blockquote><pre>
+<span class=comment>// example of a custom policy</span>
+
+<span class=keyword>class</span> <span class=identifier>custom_locking</span>
+<span class=special>{</span>
+ <span class=keyword>typedef</span> <span class=special>...</span> <span class=identifier>mutex_type</span><span class=special>;</span>
+ <span class=keyword>typedef</span> <span class=special>...</span> <span class=identifier>lock_type</span><span class=special>;</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+where <code>lock_type</code> is used to acquire/release mutexes according to
+the <code>scoped lock</code> idiom:
+</p>
+
+<blockquote><pre>
+<span class=identifier>mutex_type</span> <span class=identifier>m</span><span class=special>;</span>
+<span class=special>...</span>
+<span class=special>{</span>
+ <span class=identifier>lock_type</span> <span class=identifier>lk</span><span class=special>(</span><span class=identifier>m</span><span class=special>);</span> <span class=comment>// acquire the mutex
+ // zone of mutual exclusion, no other thread can acquire the mutex</span>
+ <span class=special>...</span>
+<span class=special>}</span> <span class=comment>// m released at lk destruction</span>
+</pre></blockquote>
+
+<p>
+Formal definitions for the concepts
+Mutex and
+Scoped Lock
+are given at the reference. To pass a locking policy as a template argument of
+<code>flyweight</code>, the class must be appropriately tagged:
+</p>
+
+<blockquote><pre>
+<span class=comment>// Alternatives for tagging a locking policy</span>
+
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>locking_tag</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=comment>// 1: Have the policy derive from locking_marker</span>
+
+<span class=keyword>struct</span> <span class=identifier>custom_locking</span><span class=special>:</span> <span class=identifier>locking_marker</span>
+<span class=special>{</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+
+<span class=comment>// 2: Specialize the is_locking class template</span>
+
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;&gt;</span> <span class=keyword>struct</span> <span class=identifier>is_locking</span><span class=special>&lt;</span><span class=identifier>custom_locking</span><span class=special>&gt;:</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>true_</span><span class=special>{};</span>
+
+<span class=special>}}</span>
+
+<span class=comment>// 3: use the locking&lt;&gt; wrapper when passing the policy
+// to flyweight</span>
+
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier>locking</span><span class=special>&lt;</span><span class=identifier>custom_locking</span><span class=special>&gt;</span>
+<span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+Note that a locking policy is its own specifier, i.e. there is no
+additional class to be passed as a proxy for the real component as is
+the case with factories and holders.
+</p>
+
+<h2><a name="tracking">Custom tracking policies</a></h2>
+
+<p>
+Tracking policies contribute some type information to the process of
+definition of the internal flyweight factory, and are given access
+to that factory to allow for the implementation of the tracking
+code. A tracking policy <code>Tracking</code> is defined as a class with
+the following nested elements:
+<ul>
+ <li>A type <code>Tracking::entry_type</code>.</li>
+ <li>A type <code>Tracking::handle_type</code>.</li>
+</ul>
+Each of these elements build on the preceding one, in the sense that
+Boost.Flyweight internal machinery funnels the results produced by an
+element into the following:
+<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&amp;</code>.
+ We saw when reviewing the factory requirements that
+ the entries stored internally by <code>flyweight&lt;T&gt;</code>
+ are not <code>T</code> objects, but rather some undisclosed type
+ convertible to <code>const T&amp;</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>.
+ </li>
+ <li>
+ The binary <a href="lambda_expressions.html"><code>Lambda
+ Expression</code></a> <code>Tracking::handle_type</code> is invoked
+ with types <code>InternalHandle</code> and <code>TrackingHandler</code>
+ to produce a type <code>Handle</code>, which will be used as the handle
+ type of the flyweight factory.
+ TrackingHandler
+ is passed as a template argument to <code>Tracking::handle_type</code>
+ to offer functionality supporting the implementation of the tracking
+ code.
+ </li>
+</ul>
+So, in order to define the factory of some instantiation
+<code>flyweight&lt;Value,...&gt;</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
+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
+the flyweight factory, and at the same time is passed a tracking helper
+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>:
+only when <code>Handle</code> is instantiated at a later stage will this
+type be complete.
+</p>
+
+<p>
+In order for a tracking policy to be passed to <code>flyweight</code>,
+it must be tagged much in the same way as the rest of specifiers.
+</p>
+
+<blockquote><pre>
+<span class=comment>// Alternatives for tagging a tracking policy</span>
+
+<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>flyweight</span><span class=special>/</span><span class=identifier>tracking_tag</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>
+
+<span class=comment>// 1: Have the policy derive from tracking_marker</span>
+
+<span class=keyword>struct</span> <span class=identifier>custom_tracking</span><span class=special>:</span> <span class=identifier><b>tracking_marker</b></span>
+<span class=special>{</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+
+<span class=comment>// 2: Specialize the is_tracking class template</span>
+
+<span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
+<span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
+
+<span class=keyword>template</span><span class=special>&lt;&gt;</span> <span class=keyword>struct</span> <span class=identifier>is_tracking</span><span class=special>&lt;</span><span class=identifier>custom_tracking</span><span class=special>&gt;:</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>true_</span><span class=special>{};</span>
+
+<span class=special>}}</span>
+
+<span class=comment>// 3: use the tracking&lt;&gt; wrapper when passing the policy
+// to flyweight</span>
+
+<span class=keyword>typedef</span> <span class=identifier>flyweight</span><span class=special>&lt;</span>
+ <span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span>
+ <span class=identifier><b>tracking</b></span><span class=special>&lt;</span><span class=identifier>custom_tracking</span><span class=special>&gt;</span>
+<span class=special>&gt;</span> <span class=identifier>flyweight_string</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+Note that a tracking policy is its own specifier, i.e. there is no
+additional class to be passed as a proxy for the real component as is
+the case with factories and holders.
+</p>
+
+<hr>
+
+<div class="prev_link"><a href="configuration.html"><img src="../prev.gif" alt="configuring Boost.Flyweight" border="0"><br>
+Configuring Boost.Flyweight
+</a></div>
+<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="lambda_expressions.html"><img src="../next.gif" alt="annex: MPL lambda expressions" border="0"><br>
+Annex: MPL lambda expressions
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised September 11th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/tutorial/flyweight_rep.png
==============================================================================
Binary file. No diff available.

Added: sandbox/flyweight/libs/flyweight/doc/tutorial/index.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/index.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,151 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Tutorial</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="../index.html">
+<link rel="up" href="../index.html">
+<link rel="next" href="basics.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" 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>
+Index
+</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="basics.html"><img src="../next.gif" alt="basics" border="0"><br>
+Basics
+</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>
+ <li>
Rationale</li>
+ <li>Namespace</li>
+ <li>Basics</li>
+ <li>Configuring Boost.Flyweight</li>
+ <li>Extending Boost.Flyweight</li>
+ <li>Annex: MPL Lambda expressions</li>
+</ul>
+
+<h2><a name="rationale">Rationale</a></h2>
+
+<span style="float:left;margin-right:20px;margin-bottom:20px">
+<p align="center">
+<img src="flyweight_rep.png"
+alt="representation of a flyweight scenario"
+width="424" height="320"><br>
+<b>Fig. 1: Representation of a flyweight scenario.</b>
+</p>
+</span>
+
+<p>
+Consider an application that has to manage large quantities of objects of
+moderate size, potentially requiring more memory than reasonably available.
+When these objects are <i>immutable</i>, i.e. they do not modify its internal
+state except maybe for reattaching to a new set of state data, and some
+additional conditions are met, a very convenient optimization technique known
+as the <i>flyweight pattern</i> can be introduced.
+</p>
+
+<p>
+Let us say there are <i>N</i> different objects living at a given time
+inside the application, globally taking <i>M</i> different values. If <i>N</i>
+is much greater than <i>M</i>, that is, there are many equivalent objects,
+we can eliminate the implicit redundancy by replacing the original objects with
+handle classes which refer to a common repository of shared value objects,
+as depicted in the figure. The handle objects or flyweights, which act as
+proxies for the actual values, typically occupy the size of a mere pointer.
+The larger the value classes, and the greater the <i>N</i>/<i>M</i> ratio,
+the more significant the memory savings achieved by this tecnhique. The
+classical example of application of the flyweight idiom is that of a word
+processor: each letter in the document carries a large wealth of
+information, such as its Unicode identifier, font, size, typesetting effects,
+etc., but given that the degree of letter repetition in a document is extremely
+high, implementing those letters as flyweight classes allows us to easily
+handle documents ranging in the hundreds of thousands of characters.
+</p>
+
+<p>
+Most presentations of the design pattern found in the literature do make a
+distinction between the flyweight <i>intrinsic information</i> (the constant
+data factored out into the repository) and <i>extrinsic</i>, mutable
+information, which is stored along with the flyweight objects or passed
+externally. This separation analysis can have some merit from the point of
+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
+appealing realization of the idiom in C++ in which
+<code>flyweight&lt;T&gt;</code> is an opaque type convertible to
+<code>const T&amp;</code>.
+</p>
+
+<p>
+The central repository of shared value objects is known as the <i>flyweight
+factory</i>. This component is able to locate and return a reference to an
+object with a given value, or insert the value if no copy was previously
+stored. Boost.Flyweight controls the interaction of flyweights with
+their factory transparently to the programmer, so that a casual user of the
+library need not even be concerned about the presence of such factory.
+Boost.Flyweight uses by default a factory based on a hashed container which
+is expected to be suitable for most situations. When this is not the case, it
+is possible to customize the factory or even replace it with another one of
+a different type, either provided by Boost.Flyweight or defined by the user.
+Other aspects of the implementation are also customizable and extendable.
+</p>
+
+<h2 clear="all" style="clear: all;">
+<a name="namespace">Namespace</a>
+</h2>
+
+<p>
+All the public types of Boost.Flyweight reside in namespace <code>::boost::flyweights</code>.
+Additionaly, the main class template <code>flyweight</code> is lifted to namespace
+<code>::boost</code> by means of a <code>using</code> declaration. For brevity of
+exposition, the fragments of code in the documentation are written as if the following
+directives were in effect:
+</p>
+
+<blockquote><pre>
+<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=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>
+
+<hr>
+
+<div class="prev_link"><a href="../index.html"><img src="../prev.gif" alt="index" border="0"><br>
+Index
+</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="basics.html"><img src="../next.gif" alt="basics" border="0"><br>
+Basics
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised August 16th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/doc/tutorial/lambda_expressions.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,180 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Boost.Flyweight Documentation - Tutorial - Annex - MPL lambda expressions</title>
+<link rel="stylesheet" href="../style.css" type="text/css">
+<link rel="start" href="../index.html">
+<link rel="prev" href="extension.html">
+<link rel="up" href="index.html">
+<link rel="next" href="../reference/index.html">
+</head>
+
+<body>
+<h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
+"middle" width="277" height="86">Boost.Flyweight Tutorial Annex: MPL lambda expressions</h1>
+
+<div class="prev_link"><a href="extension.html"><img src="../prev.gif" alt="extending Boost.Flyweight" border="0"><br>
+Extending Boost.Flyweight
+</a></div>
+<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="../reference/index.html"><img src="../next.gif" alt="Boost.Flyweight reference" border="0"><br>
+Boost.Flyweight reference
+</a></div><br clear="all" style="clear: all;">
+
+<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
+for further information beyond these introductory notes.
+</p>
+
+<p>
+The specifiers defined by Boost.Flyweight rely heavily on the
+<a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>Lambda
+Expression</code></a> concept defined by the
+Boost MPL Library. A lambda
+expression can be thought of as a compile-time "type function", an entity (a
+concrete type, actually) that can be invoked with a list of types and returns
+some associated type in its turn. Consider for instance an arbitrary class
+template:
+</p>
+
+<blockquote><pre>
+<span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Q</span><span class=special>&gt;</span>
+<span class=keyword>class</span> <span class=identifier>foo</span>
+<span class=special>{</span>
+ <span class=special>...</span>
+<span class=special>};</span>
+</pre></blockquote>
+
+<p>
+and suppose we want to have a lambda expression that, when invoked
+with some generic types <code>Arg1</code> and <code>Arg2</code>,
+returns <code>foo&lt;Arg1,Arg2&gt;</code>. Such a lambda expression
+can be implemented in two ways
+<ol>
+ <li>As a
+ <a href="../../../mpl/doc/refmanual/metafunction-class.html"><code>MPL
+ Metafunction Class</code></a>, a type with a special nested class template
+ named <code>apply</code>:
+<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>&lt;</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>&gt;</span>
+ <span class=keyword>struct</span> <span class=identifier>apply</span>
+ <span class=special>{</span>
+ <span class=comment>// this is the &quot;return type&quot; of foo_specifier</span>
+ <span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special>&lt;</span><span class=identifier>Arg1</span><span class=special>,</span><span class=identifier>Arg2</span><span class=special>&gt;</span> <span class=identifier>type</span><span class=special>;</span>
+ <span class=special>};</span>
+<span class=special>};</span>
+</pre></blockquote>
+ </li>
+ <li>
+ As a
+ <a href="../../../mpl/doc/refmanual/placeholder-expression.html"><code>MPL
+ Placeholder Expression</code></a>, a class template instantiated with one or
+ more <i>placeholders</i>:
+<blockquote><pre>
+<span class=keyword>typedef</span> <span class=identifier>foo</span><span class=special>&lt;</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>&gt;</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&lt;std::string&gt</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
+ be substituted for actual types (the first and second type supplied,
+ respectively) when <code>foo_specifier</code> is
+ invoked. So, an instantiation of <code>foo</code> can be used
+ to refer back to the <code>foo</code> class template itself! The net
+ effect is the same as with metafunctions, but placeholder expressions spare
+ us the need to write boilerplate metafunction classes
+ --and the kind of metaprogramming magic they depend on has an undeniable
+ beauty to it.
+ </li>
+</ol>
+So far the examples shown just forward the arguments <code>Arg1</code> and
+<code>Arg2</code> directly to a class template without further elaboration,
+but there is nothing preventing us from doing some argument manipulation,
+like, for instance, switching their places:
+</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>&lt;</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>&gt;</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>&lt;</span><span class=identifier>Arg2</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>&gt;</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>&lt;</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>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_1</span><span class=special>&gt;</span> <span class=identifier>foo_specifier</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+trasforming them:
+</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>&lt;</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>&gt;</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>&lt;</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>&lt;</span><span class=identifier>Arg2</span><span class=special>&gt;</span> <span class=special>&gt;</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>&lt;</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>&lt;</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>&gt;</span> <span class=special>&gt;</span> <span class=identifier>foo_specifier</span><span class=special>;</span>
+</pre></blockquote>
+
+<p>
+or accepting less or more arguments than the class template itself
+(the number of parameters of a lambda expression is called its <i>arity</i>):
+</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>&lt;</span><span class=keyword>typename</span> <span class=identifier>Arg1</span><span class=special>&gt;</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>&lt;</span><span class=identifier>Arg1</span><span class=special>,</span><span class=identifier>Arg1</span><span class=special>*&gt;</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>&lt;</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>&lt;</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>*&gt;</span> <span class=special>&gt;</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>
+ <span class=keyword>template</span><span class=special>&lt;</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>typename</span> <span class=identifier>Arg3</span><span class=special>&gt;</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>&lt;</span><span class=identifier>Arg1</span><span class=special>,</span><span class=identifier>foo</span><span class=special>&lt;</span><span class=identifier>Arg2</span><span class=special>,</span><span class=identifier>Arg3</span><span class=special>&gt;</span> <span class=special>&gt;</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>&lt;</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>foo</span><span class=special>&lt;</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>boost</span><span class=special>::</span><span class=identifier>mpl</span><span class=special>::</span><span class=identifier>_3</span><span class=special>&gt;</span> <span class=special>&gt;</span> <span class=identifier>foo_specifier</span><span class=special>;</span>
+</pre></blockquote>
+
+<hr>
+
+<div class="prev_link"><a href="extension.html"><img src="../prev.gif" alt="extending Boost.Flyweight" border="0"><br>
+Extending Boost.Flyweight
+</a></div>
+<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="../reference/index.html"><img src="../next.gif" alt="Boost.Flyweight reference" border="0"><br>
+Boost.Flyweight reference
+</a></div><br clear="all" style="clear: all;">
+
+<br>
+
+<p>Revised August 16th 2007</p>
+
+<p>&copy; Copyright 2006-2007 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;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">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/doc/up.gif
==============================================================================
Binary file. No diff available.

Added: sandbox/flyweight/libs/flyweight/example/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/example/Jamfile.v2 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,34 @@
+# Boost.Flyweight examples Jamfile
+#
+# Copyright 2006-2007 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)
+#
+# See http://www.boost.org/libs/multi_index for library home page.
+
+exe basic
+ : basic.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
+exe composite
+ : composite.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
+exe html
+ : html.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
+exe perf
+ : perf.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
+exe serialization
+ : serialization.cpp
+ /boost/serialization//boost_serialization/<link>static
+ : <include>$(BOOST_ROOT)
+ ;

Added: sandbox/flyweight/libs/flyweight/example/basic.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/example/basic.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,152 @@
+/* Boost.Flyweight basic example.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/bind.hpp>
+#include <boost/flyweight.hpp>
+#include <algorithm>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <string>
+#include <vector>
+
+using namespace boost::flyweights;
+
+/* Information associated to a given user of some massive system.
+ * first_name and last_name are turned into flyweights to leverage the
+ * implicit redundancy of names within the user community.
+ */
+
+struct user_entry
+{
+ flyweight<std::string> first_name;
+ flyweight<std::string> last_name;
+ int age;
+
+ user_entry();
+ user_entry(const char* first_name,const char* last_name,int age);
+ user_entry(const user_entry& x);
+};
+
+/* flyweight<std::string> default ctor simply calls the default ctor of
+ * std::string.
+ */
+
+user_entry::user_entry()
+{}
+
+/* flyweight<std::string> is constructible from a const char* much as
+ * a std::string is.
+ */
+
+user_entry::user_entry(const char* f,const char* l,int a):
+ first_name(f),
+ last_name(l),
+ age(a)
+{}
+
+/* flyweight's are copyable and assignable --unlike std::string,
+ * copy and assignment of flyweight<std::string>s do not ever throw.
+ */
+
+user_entry::user_entry(const user_entry& x):
+ first_name(x.first_name),
+ last_name(x.last_name),
+ age(x.age)
+{}
+
+/* flyweight<std::string> has operator==,!=,<,>,<=,>= with the same
+ * semantics as those of std::string.
+ */
+
+bool same_name(const user_entry& user1,const user_entry& user2)
+{
+ bool b=user1.first_name==user2.first_name &&
+ user1.last_name==user2.last_name;
+ return b;
+}
+
+/* operator<< forwards to the std::string overload */
+
+std::ostream& operator<<(std::ostream& os,const user_entry& user)
+{
+ return os<<user.first_name<<" "<<user.last_name<<" "<<user.age;
+}
+
+/* operator>> internally uses std::string's operator>> */
+
+std::istream& operator>>(std::istream& is,user_entry& user)
+{
+ return is>>user.first_name>>user.last_name>>user.age;
+}
+
+std::string full_name(const user_entry& user)
+{
+ std::string full;
+
+ /* get() returns the underlying const std::string& */
+
+ full.reserve(
+ user.first_name.get().size()+user.last_name.get().size()+1);
+
+ /* here, on the other hand, implicit conversion is used */
+
+ full+=user.first_name;
+ full+=" ";
+ full+=user.last_name;
+
+ return full;
+}
+
+/* flyweight<std::string> value is immutable, but a flyweight object can
+ * be assigned a different value.
+ */
+
+void change_name(user_entry& user,const std::string& f,const std::string& l)
+{
+ user.first_name=f;
+ user.last_name=l;
+}
+
+int main()
+{
+ /* play a little with a vector of user_entry's */
+
+ std::string users_txt=
+ "olegh smith 31\n"
+ "john brown 28\n"
+ "anna jones 45\n"
+ "maria garcia 30\n"
+ "john fox 56\n"
+ "anna brown 19\n"
+ "thomas smith 46\n"
+ "andrew martin 28";
+
+ std::vector<user_entry> users;
+ std::istringstream iss(users_txt);
+ while(iss){
+ user_entry u;
+ if(iss>>u)users.push_back(u);
+ }
+
+ change_name(users[0],"oleg","smith");
+
+ user_entry anna("anna","jones",20);
+ std::replace_if(
+ users.begin(),users.end(),
+ boost::bind(same_name,_1,anna),
+ anna);
+
+ std::copy(
+ users.begin(),users.end(),
+ std::ostream_iterator<user_entry>(std::cout,"\n"));
+
+ return 0;
+}

Added: sandbox/flyweight/libs/flyweight/example/composite.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/example/composite.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,179 @@
+/* Boost.Flyweight example of a composite design.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/flyweight.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/tokenizer.hpp>
+#include <boost/variant.hpp>
+#include <boost/variant/apply_visitor.hpp>
+#include <boost/variant/recursive_wrapper.hpp>
+#include <iostream>
+#include <stdexcept>
+#include <string>
+#include <vector>
+
+using namespace boost::flyweights;
+
+/* A node of a lisp-like list can be modeled as a boost::variant of
+ * 1. A string (primitive node)
+ * 2. A vector of nodes (embedded list)
+ * To save space, 2 is stored as a vector of flyweights.
+ * As is usual with recursive data structures, a node can be thought
+ * of also as a list. To close the flyweight circle, the final
+ * type list is a flyweight wrapper, so that the final structure can
+ * be described as follows in BNF-like style:
+ *
+ * list ::= flyweight<list_impl>
+ * list_impl ::= std::string | std::vector<list>
+ */
+
+struct list_elems;
+
+typedef boost::variant<
+ std::string,
+ boost::recursive_wrapper<list_elems>
+> list_impl;
+
+struct list_elems:std::vector<flyweight<list_impl> >{};
+
+typedef flyweight<list_impl> list;
+
+/* list_impl must be hashable to be used by flyweight: If a
+ * node is a std::string, its hash resolves to that of the string;
+ * if it is a vector of nodes, we compute the hash by combining
+ * the *addresses* of the stored flyweights' associated values: this is
+ * consistent because flyweight equality implies equality of reference.
+ * Using this trick instead of hashing the node values themselves
+ * allow us to do the computation without recursively descending down
+ * through the entire data structure.
+ */
+
+struct list_hasher:boost::static_visitor<std::size_t>
+{
+ std::size_t operator()(const std::string& str)const
+ {
+ boost::hash<std::string> h;
+ return h(str);
+ }
+
+ std::size_t operator()(
+ const boost::recursive_wrapper<list_elems>& elmsw)const
+ {
+ const list_elems& elms=elmsw.get();
+ std::size_t res=0;
+ for(list_elems::const_iterator it=elms.begin(),it_end=elms.end();
+ it!=it_end;++it){
+ const list_impl* p=&it->get();
+ boost::hash_combine(res,p);
+ }
+ return res;
+ }
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+std::size_t hash_value(const list_impl& limpl)
+{
+ return boost::apply_visitor(list_hasher(),limpl);
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+/* basic pretty printer with indentation according to the nesting level */
+
+struct list_pretty_printer:boost::static_visitor<>
+{
+ list_pretty_printer():nest(0){}
+
+ void operator()(const std::string& str)
+ {
+ indent();
+ std::cout<<str<<"\n";
+ }
+
+ void operator()(const boost::recursive_wrapper<list_elems>& elmsw)
+ {
+ indent();
+ std::cout<<"(\n";
+ ++nest;
+ const list_elems& elms=elmsw.get();
+ for(list_elems::const_iterator it=elms.begin(),it_end=elms.end();
+ it!=it_end;++it){
+ boost::apply_visitor(*this,it->get());
+ }
+ --nest;
+ indent();
+ std::cout<<")\n";
+ }
+
+private:
+ void indent()const
+ {
+ for(int i=nest;i--;)std::cout<<" ";
+ }
+
+ int nest;
+};
+
+void pretty_print(const list& l)
+{
+ list_pretty_printer pp;
+ boost::apply_visitor(pp,l.get());
+}
+
+/* list parser */
+
+template<typename InputIterator>
+list parse_list(InputIterator& first,InputIterator last,int nest)
+{
+ list_elems elms;
+ while(first!=last){
+ std::string str=*first++;
+ if(str=="("){
+ elms.push_back(parse_list(first,last,nest+1));
+ }
+ else if(str==")"){
+ if(nest==0)throw std::runtime_error("unmatched )");
+ return list(elms);
+ }
+ else{
+ elms.push_back(list(str));
+ }
+ }
+ if(nest!=0)throw std::runtime_error("unmatched (");
+ return list(elms);
+}
+
+list parse_list(const std::string str)
+{
+ typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+ tokenizer tok(str,boost::char_separator<char>(" ","()"));
+ tokenizer::iterator begin=tok.begin();
+ return parse_list(begin,tok.end(),0);
+}
+
+int main()
+{
+ std::cout<<"enter list: ";
+ std::string str;
+ std::getline(std::cin,str);
+ try{
+ pretty_print(parse_list(str));
+ }
+ catch(const std::exception& e){
+ std::cout<<"error: "<<e.what()<<"\n";
+ }
+
+ return 0;
+}

Added: sandbox/flyweight/libs/flyweight/example/html.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/example/html.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,343 @@
+/* Boost.Flyweight example of flyweight-based formatted text processing.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/flyweight.hpp>
+#include <boost/functional/hash.hpp>
+#include <algorithm>
+#include <cctype>
+#include <cstdio>
+#include <fstream>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#if defined(BOOST_NO_STDC_NAMESPACE)
+namespace std{using ::exit;using ::tolower;}
+#endif
+
+using namespace boost::flyweights;
+
+/* See the portability section of Boost.Hash at
+ * http://boost.org/doc/html/hash/portability.html
+ * for an explanation of the ADL-related workarounds.
+ */
+
+namespace boost{
+#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace flyweights{
+#endif
+
+/* We hash the various flyweight types used in the program hashing
+ * a *pointer* to their contents: this is consistent as equality of
+ * flyweights implies equality of references.
+ */
+
+template<typename T>
+std::size_t hash_value(const flyweight<T>& x)
+{
+ boost::hash<const T*> h;
+ return h(&x.get());
+}
+
+#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace flyweights */
+#endif
+} /* namespace boost */
+
+/* An HTML tag consists of a name and optional properties of the form
+ * name1=value1 ... namen=valuen. We do not need to parse the properties
+ * for the purposes of the program, hence they are all stored in
+ * html_tag_data::properties in raw form.
+ */
+
+struct html_tag_data
+{
+ std::string name;
+ std::string properties;
+};
+
+bool operator==(const html_tag_data& x,const html_tag_data& y)
+{
+ return x.name==y.name&&x.properties==y.properties;
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+std::size_t hash_value(const html_tag_data& x)
+{
+ std::size_t res=0;
+ boost::hash_combine(res,x.name);
+ boost::hash_combine(res,x.properties);
+ return res;
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+typedef flyweight<html_tag_data> html_tag;
+
+/* parse_tag is passed an iterator positioned at the first char of
+ * the tag after the opening '<' and returns, if succesful, a parsed tag
+ * and whether it is opening (<xx>) or closing (</xx>).
+ */
+
+enum tag_type{opening,closing,failure};
+
+struct parse_tag_res
+{
+ parse_tag_res(tag_type type_,const html_tag_data& tag_=html_tag_data()):
+ type(type_),tag(tag_){}
+ parse_tag_res(const parse_tag_res& x):type(x.type),tag(x.tag){}
+
+ tag_type type;
+ html_tag tag;
+};
+
+template<typename ForwardIterator>
+parse_tag_res parse_tag(ForwardIterator& first,ForwardIterator last)
+{
+ html_tag_data tag;
+ std::string buf;
+ bool in_quote=false;
+ for(ForwardIterator it=first;it!=last;){
+ char ch=*it++;
+ if(ch=='>'&&!in_quote){ /* ignore '>'s if inside quotes */
+ tag_type type;
+ std::string::size_type
+ bname=buf.find_first_not_of("\t\n\r "),
+ ename=bname==std::string::npos?
+ std::string::npos:
+ buf.find_first_of("\t\n\r ",bname),
+ bprop=ename==std::string::npos?
+ std::string::npos:
+ buf.find_first_not_of("\t\n\r ",ename);
+ if(bname==ename){ /* null name */
+ return parse_tag_res(failure);
+ }
+ else if(buf[bname]=='/'){ /* closing tag */
+ type=closing;
+ ++bname;
+ }
+ else type=opening;
+ tag.name=buf.substr(bname,ename-bname);
+ std::transform( /* normalize tag name to lower case */
+ tag.name.begin(),tag.name.end(),tag.name.begin(),
+ (int(*)(int))std::tolower);
+ if(bprop!=std::string::npos){
+ tag.properties=buf.substr(bprop,buf.size());
+ }
+ first=it; /* result good, consume the chars */
+ return parse_tag_res(type,tag);
+ }
+ else{
+ if(ch=='"')in_quote=!in_quote;
+ buf+=ch;
+ }
+ }
+ return parse_tag_res(failure); /* end reached and found no '>' */
+}
+
+/* A character context is just a vector containing the tags enclosing the
+ * character, from the outermost level to the innermost.
+ */
+
+typedef std::vector<html_tag> html_context_data;
+typedef flyweight<html_context_data> html_context;
+
+/* A character is a char code plus its context.
+ */
+
+struct character_data
+{
+ character_data(char code_=0,html_context context_=html_context()):
+ code(code_),context(context_){}
+ character_data(const character_data& x):code(x.code),context(x.context){}
+
+ char code;
+ html_context context;
+};
+
+bool operator==(const character_data& x,const character_data& y)
+{
+ return x.code==y.code&&x.context==y.context;
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+std::size_t hash_value(const character_data& x)
+{
+ std::size_t res=0;
+ boost::hash_combine(res,x.code);
+ boost::hash_combine(res,x.context);
+ return res;
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+typedef flyweight<character_data> character;
+
+/* scan_html converts HTML code into a stream of contextualized characters.
+ */
+
+template<typename ForwardIterator,typename OutputIterator>
+void scan_html(ForwardIterator first,ForwardIterator last,OutputIterator out)
+{
+ html_context_data context;
+ while(first!=last){
+ if(*first=='<'){ /* tag found */
+ ++first;
+ parse_tag_res res=parse_tag(first,last);
+ if(res.type==opening){ /* add to contex */
+ context.push_back(res.tag);
+ continue;
+ }
+ else if(res.type==closing){ /* remove from context */
+ /* Pop all tags from the innermost to the matching one; this takes
+ * care of missing </xx>s like vg. in <ul><li>hello</ul>.
+ */
+
+ for(html_context_data::reverse_iterator rit=context.rbegin();
+ rit!=context.rend();++rit){
+ if(rit->get().name==res.tag.get().name){
+ context.erase(rit.base()-1,context.end());
+ break;
+ }
+ }
+ continue;
+ }
+ }
+ *out++=character(*first++,html_context(context));
+ }
+}
+
+/* HTML-producing utilities */
+
+void print_opening_tag(std::ostream& os,const html_tag_data& x)
+{
+ os<<"<"<<x.name;
+ if(!x.properties.empty())os<<" "<<x.properties;
+ os<<">";
+}
+
+void print_closing_tag(std::ostream& os,const html_tag_data& x)
+{
+ /* SGML declarations (beginning with '!') are not closed */
+
+ if(x.name[0]!='!')os<<"</"<<x.name<<">";
+}
+
+/* change_context takes contexts from and to with tags
+ *
+ * from<- c1 ... cn fn+1 ... fm
+ * to <- c1 ... cn tn+1 ... tk
+ *
+ * (that is, they share the first n tags, n might be 0), and
+ * produces code closing fm ... fn+1 and opening tn+1 ... tk.
+ */
+
+template<typename OutputIterator>
+void change_context(
+ const html_context_data& from,const html_context_data& to,
+ OutputIterator out)
+{
+ std::ostringstream oss;
+ html_context_data::const_iterator
+ it0=from.begin(),
+ it0_end=from.end(),
+ it1=to.begin(),
+ it1_end=to.end();
+ for(;it0!=it0_end&&it1!=it1_end&&*it0==*it1;++it0,++it1);
+ while(it0_end!=it0)print_closing_tag(oss,*--it0_end);
+ while(it1!=it1_end)print_opening_tag(oss,*it1++);
+ std::string str=oss.str();
+ std::copy(str.begin(),str.end(),out);
+}
+
+/* produce_html is passed a bunch of contextualized characters and emits
+ * the corresponding HTML. The algorithm is simple: tags are opened and closed
+ * as a result of the context from one character to the following changing.
+ */
+
+template<typename ForwardIterator,typename OutputIterator>
+void produce_html(ForwardIterator first,ForwardIterator last,OutputIterator out)
+{
+ html_context context;
+ while(first!=last){
+ if(first->get().context!=context){
+ change_context(context,first->get().context,out);
+ context=first->get().context;
+ }
+ *out++=(first++)->get().code;
+ }
+ change_context(context,html_context(),out); /* close remaining context */
+}
+
+/* Without these explicit instantiations, MSVC++ 6.5/7.0 does not
+ * find some friend operators in certain contexts.
+ */
+
+character dummy1;
+html_tag dummy2;
+
+int main()
+{
+ std::cout<<"input html file: ";
+ std::string in;
+ std::getline(std::cin,in);
+ std::ifstream ifs(in.c_str());
+ if(!ifs){
+ std::cout<<"can't open "<<in<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ typedef std::istreambuf_iterator<char> istrbuf_iterator;
+ std::vector<char> html_source;
+ std::copy(
+ istrbuf_iterator(ifs),istrbuf_iterator(),
+ std::back_inserter(html_source));
+
+ /* parse the HTML */
+
+ std::vector<character> scanned_html;
+ scan_html(
+ html_source.begin(),html_source.end(),std::back_inserter(scanned_html));
+
+ /* Now that we have the text as a vector of contextualized characters,
+ * we can shuffle it around and manipulate in almost any way we please.
+ * For instance, the following reverses the central portion of the doc.
+ */
+
+ std::reverse(
+ scanned_html.begin()+scanned_html.size()/4,
+ scanned_html.begin()+3*(scanned_html.size()/4));
+
+ /* emit the resulting HTML */
+
+ std::cout<<"output html file: ";
+ std::string out;
+ std::getline(std::cin,out);
+ std::ofstream ofs(out.c_str());
+ if(!ofs){
+ std::cout<<"can't open "<<out<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ typedef std::ostreambuf_iterator<char> ostrbuf_iterator;
+ produce_html(scanned_html.begin(),scanned_html.end(),ostrbuf_iterator(ofs));
+
+ return 0;
+}

Added: sandbox/flyweight/libs/flyweight/example/perf.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/example/perf.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,294 @@
+/* Boost.Flyweight example of performance comparison.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/set_factory.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/no_tracking.hpp>
+#include <boost/tokenizer.hpp>
+#include <algorithm>
+#include <cstddef>
+#include <cstdlib>
+#include <ctime>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#if defined(BOOST_NO_STDC_NAMESPACE)
+namespace std{
+using ::clock;
+using ::clock_t;
+using ::exit;
+}
+#endif
+
+using namespace boost::flyweights;
+
+/* Instrumented allocator family keeping track of the memory in
+ * current use.
+ */
+
+std::size_t count_allocator_mem=0;
+
+template<typename T>
+class count_allocator
+{
+public:
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+ template<class U>struct rebind{typedef count_allocator<U> other;};
+
+ count_allocator(){}
+ count_allocator(const count_allocator<T>&){}
+ template<class U>count_allocator(const count_allocator<U>&,int=0){}
+
+ pointer address(reference x)const{return &x;}
+ const_pointer address(const_reference x)const{return &x;}
+
+ pointer allocate(size_type n,const void* =0)
+ {
+ pointer p=(T*)(new char[n*sizeof(T)]);
+ count_allocator_mem+=n*sizeof(T);
+ 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);
+ delete [](char *)p;
+ }
+
+ size_type max_size() const{return (size_type )(-1);}
+ void construct(pointer p,const T& val){new(p)T(val);}
+ void destroy(pointer p){p->~T();}
+
+ friend bool operator==(const count_allocator&,const count_allocator&)
+ {
+ return true;
+ }
+
+ friend bool operator!=(const count_allocator&,const count_allocator&)
+ {
+ return false;
+ }
+};
+
+template<>
+class count_allocator<void>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template<class U>struct rebind{typedef count_allocator<U> other;};
+};
+
+/* Define some count_allocator-based types and Boost.Flyweight components */
+
+typedef std::basic_string<
+ 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>
+> count_hashed_factory;
+
+typedef set_factory<
+ std::less<count_string>,
+ count_allocator<count_string>
+> 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
+{
+ template<typename Entry,typename Value>
+ struct apply
+ {
+ typedef hashed_factory_class<
+ Entry,Value,
+ boost::hash<Value>,
+ std::equal_to<Value>,
+ count_allocator<Entry>
+ > type;
+ };
+};
+
+struct count_set_factory:factory_marker
+{
+ template<typename Entry,typename Value>
+ struct apply
+ {
+ typedef set_factory_class<
+ Entry,Value,
+ std::less<Value>,
+ count_allocator<Entry>
+ > type;
+ };
+};
+#endif
+
+/* Measure time and memory performance for a String, which is assumed
+ * to be either a plain string type or a string flyweight.
+ */
+
+template<typename String>
+struct test
+{
+ static void run(const std::string& file)
+ {
+ typedef std::vector<String,count_allocator<String> > count_vector;
+
+ /* Define a tokenizer on std::istreambuf. */
+
+ typedef std::istreambuf_iterator<char> char_iterator;
+ typedef boost::tokenizer<
+ boost::char_separator<char>,
+ char_iterator
+ > tokenizer;
+
+ std::ifstream ifs(file.c_str());
+ if(!ifs){
+ std::cout<<"can't open "<<file<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+
+ std::clock_t start=std::clock();
+
+ /* Tokenize using space and common punctuaction as separators, and
+ * keeping the separators.
+ */
+
+ tokenizer tok=tokenizer(
+ char_iterator(ifs),char_iterator(),
+ boost::char_separator<char>(
+ "",
+ "\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"));
+ count_vector txt;
+ for(tokenizer::iterator it=tok.begin();it!=tok.end();++it){
+ txt.push_back(String(it->c_str()));
+ }
+
+ /* Do some text handling */
+
+ std::sort(txt.begin(),txt.end());
+ std::random_shuffle(txt.begin(),txt.end());
+
+ std::cout<<"Time used: "<<(double)(std::clock()-start)/CLOCKS_PER_SEC
+ <<" s\n";
+ std::cout<<"Bytes used: "<<count_allocator_mem<<"\n";
+ }
+};
+
+
+/* table of test cases for the user to select from */
+
+struct test_case
+{
+ const char* name;
+ 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[]=
+{
+ {
+ "simple string",
+ test<count_string>::run
+ },
+ {
+ "flyweight, hashed factory",
+ test<flyweight<count_string,count_hashed_factory> >::run
+ },
+ {
+ "flyweight, hashed factory, no tracking",
+ test<flyweight<count_string,count_hashed_factory,no_tracking> >::run
+ },
+ {
+ "flyweight, set-based factory",
+ test<flyweight<count_string,count_set_factory> >::run
+ },
+ {
+ "flyweight, set-based factory, no tracking",
+ test<flyweight<count_string,count_set_factory,no_tracking> >::run
+ }
+};
+
+enum{num_test_cases=sizeof(test_table)/sizeof(test_case)};
+
+int main()
+{
+ try{
+ for(int i=0;i<num_test_cases;++i){
+ std::cout<<i+1<<". "<<test_table[i].name<<"\n";
+ }
+ int option=-1;
+ for(;;){
+ std::cout<<"select option, enter to exit: ";
+ std::string str;
+ std::getline(std::cin,str);
+ if(str.empty())std::exit(EXIT_SUCCESS);
+ std::istringstream istr(str);
+ istr>>option;
+ if(option>=1&&option<=num_test_cases){
+ --option; /* pass from 1-based menu to 0-based test_table */
+ break;
+ }
+ }
+
+ std::cout<<"enter file name: ";
+ std::string file;
+ std::getline(std::cin,file);
+ test_table[option].test(file);
+ }
+ catch(const std::exception& e){
+ std::cout<<"error: "<<e.what()<<"\n";
+ }
+
+ return 0;
+}

Added: sandbox/flyweight/libs/flyweight/example/serialization.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/example/serialization.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,137 @@
+/* Boost.Flyweight example of serialization.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <algorithm>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/flyweight.hpp>
+#include <boost/flyweight/serialize.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/tokenizer.hpp>
+#include <cstdio>
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <stdexcept>
+#include <string>
+#include <vector>
+
+#if defined(BOOST_NO_STDC_NAMESPACE)
+namespace std{using ::exit;}
+#endif
+
+using namespace boost::flyweights;
+
+typedef flyweight<std::string> fw_string;
+typedef std::vector<fw_string> text_container;
+
+/* Read a text file into a text_container and serialize to an archive. */
+
+void save_serialization_file()
+{
+ /* Define a tokenizer on std::istreambuf. */
+
+ typedef std::istreambuf_iterator<char> char_iterator;
+ typedef boost::tokenizer<
+ boost::char_separator<char>,
+ char_iterator
+ > tokenizer;
+
+ std::cout<<"enter input text file name: ";
+ std::string in;
+ std::getline(std::cin,in);
+ std::ifstream ifs(in.c_str());
+ if(!ifs){
+ std::cout<<"can't open "<<in<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+
+ /* Tokenize using space and common punctuaction as separators, and
+ * keeping the separators.
+ */
+
+ tokenizer tok=tokenizer(
+ char_iterator(ifs),char_iterator(),
+ boost::char_separator<char>(
+ "",
+ "\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"));
+ text_container txt;
+ for(tokenizer::iterator it=tok.begin();it!=tok.end();++it){
+ txt.push_back(fw_string(*it));
+ }
+
+ std::cout<<"enter output serialization file name: ";
+ std::string out;
+ std::getline(std::cin,out);
+ std::ofstream ofs(out.c_str());
+ if(!ofs){
+ std::cout<<"can't open "<<out<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ boost::archive::text_oarchive oa(ofs);
+ oa<<const_cast<const text_container&>(txt);
+}
+
+/* Read a serialization archive and save the result to a text file. */
+
+void load_serialization_file()
+{
+ std::cout<<"enter input serialization file name: ";
+ std::string in;
+ std::getline(std::cin,in);
+ std::ifstream ifs(in.c_str());
+ if(!ifs){
+ std::cout<<"can't open "<<in<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ boost::archive::text_iarchive ia(ifs);
+ text_container txt;
+ ia>>txt;
+
+ std::cout<<"enter output text file name: ";
+ std::string out;
+ std::getline(std::cin,out);
+ std::ofstream ofs(out.c_str());
+ if(!ofs){
+ std::cout<<"can't open "<<out<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ std::copy(
+ txt.begin(),txt.end(),
+ std::ostream_iterator<std::string>(ofs));
+}
+
+int main()
+{
+ try{
+ std::cout<<"1 load a text file and save it as a serialization file\n"
+ "2 load a serialization file and save it as a text file\n";
+ for(;;){
+ std::cout<<"select option, enter to exit: ";
+ std::string str;
+ std::getline(std::cin,str);
+ if(str.empty())break;
+ std::istringstream istr(str);
+ int option=-1;
+ istr>>option;
+ if(option==1)save_serialization_file();
+ else if(option==2)load_serialization_file();
+ }
+ }
+ catch(const std::exception& e){
+ std::cout<<"error: "<<e.what()<<std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+
+ return 0;
+}

Added: sandbox/flyweight/libs/flyweight/index.html
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/index.html 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
+<!--
+ Copyright 2006 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)
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<meta http-equiv="refresh" content="0; URL=doc/index.html">
+<title>Boost.Flyweight Documentation</title>
+<link rel="stylesheet" href="doc/style.css" type="text/css">
+</head>
+
+<body>
+Automatic redirection failed, please go to
+doc/index.html
+</body>
+</html>

Added: sandbox/flyweight/libs/flyweight/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/Jamfile.v2 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,30 @@
+# Boost.Flyweight tests Jamfile
+#
+# Copyright 2006-2007 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)
+#
+# See http://www.boost.org/libs/flyweight for library home page.
+
+test-suite "flyweight" :
+ [ run test_assoc_cont_factory.cpp test_assoc_cont_fact_main.cpp ]
+ [ run test_basic.cpp test_basic_main.cpp ]
+ [ run test_custom_factory.cpp test_custom_factory_main.cpp ]
+ [ run test_intermod_holder.cpp test_intermod_holder_main.cpp
+ intermod_holder_dll
+ : # command line
+ : # input files
+ : # requirements
+ <threading>multi ]
+ [ run test_multictor.cpp test_multictor_main.cpp ]
+ [ run test_no_locking.cpp test_no_locking_main.cpp ]
+ [ run test_no_tracking.cpp test_no_tracking_main.cpp ]
+ [ run test_serialization.cpp test_serialization_main.cpp
+ /boost/serialization//boost_serialization/<link>static ]
+ [ run test_set_factory.cpp test_set_factory_main.cpp ]
+ ;
+
+lib intermod_holder_dll : intermod_holder_dll.cpp :
+ <link>shared
+ <define>BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_SOURCE=1 ;

Added: sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,17 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "intermod_holder_dll.hpp"
+
+intermodule_flyweight_string create_intermodule_flyweight_string(
+ const std::string& str)
+{
+ return intermodule_flyweight_string(str);
+}

Added: sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/intermod_holder_dll.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,45 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_HPP
+#define BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/intermodule_holder.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <string>
+
+#ifdef BOOST_HAS_DECLSPEC
+#ifdef BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_SOURCE
+#define BOOST_FLYWEIGHT_DLL_DECL __declspec(dllexport)
+#else
+#define BOOST_FLYWEIGHT_DLL_DECL __declspec(dllimport)
+#endif
+#else
+#define BOOST_FLYWEIGHT_DLL_DECL
+#endif
+
+typedef boost::flyweights::flyweight<
+ std::string,
+ boost::flyweights::intermodule_holder> intermodule_flyweight_string;
+
+BOOST_FLYWEIGHT_DLL_DECL intermodule_flyweight_string
+create_intermodule_flyweight_string(const std::string&);
+
+#undef BOOST_FLYWEIGHT_DLL_DECL
+
+#endif

Added: sandbox/flyweight/libs/flyweight/test/lambda_components.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/lambda_components.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,64 @@
+/* Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_LAMBDA_COMPONENTS_HPP
+#define BOOST_FLYWEIGHT_TEST_LAMBDA_COMPONENTS_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/functional/hash.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <functional>
+#include <set>
+
+/* Lambda-enabled replacements for some std:: and boost:: components.
+ * These are not really necessary in conformant compilers.
+ */
+
+template<typename T>
+struct lambda_greater:std::greater<T>
+{
+ typedef lambda_greater type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,lambda_greater,(T))
+};
+
+template<typename T>
+struct lambda_equal_to:std::equal_to<T>
+{
+ typedef lambda_equal_to type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,lambda_equal_to,(T))
+};
+
+template<typename T>
+struct lambda_hash:boost::hash<T>
+{
+ typedef lambda_hash type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,lambda_hash,(T))
+};
+
+template<typename T>
+struct lambda_less:std::less<T>
+{
+ typedef lambda_less type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,lambda_less,(T))
+};
+
+template<
+ typename T,
+ typename Compare=std::less<T>,typename Allocator=std::allocator<T>
+>
+struct lambda_set:std::set<T,Compare,Allocator>
+{
+ typedef lambda_set type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(3,lambda_set,(T,Compare,Allocator))
+};
+
+#endif

Added: sandbox/flyweight/libs/flyweight/test/test_all_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_all_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,44 @@
+/* Boost.Flyweight test suite.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/lightweight_test.hpp>
+#include "test_assoc_cont_factory.hpp"
+#include "test_basic.hpp"
+#include "test_custom_factory.hpp"
+#include "test_intermod_holder.hpp"
+#include "test_multictor.hpp"
+#include "test_no_locking.hpp"
+#include "test_no_tracking.hpp"
+#include "test_serialization.hpp"
+#include "test_set_factory.hpp"
+
+int main()
+{
+ test_assoc_container_factory();
+ test_basic();
+ test_custom_factory();
+
+#if !defined(BOOST_MSVC)||!(BOOST_MSVC<1300)
+ test_intermodule_holder();
+#endif
+
+ test_multictor();
+ test_no_locking();
+ test_no_tracking();
+
+#if 0 /* #if'ed out til we get Boost.Serialization helper API back */
+ test_serialization();
+#endif
+
+ test_set_factory();
+
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_assoc_cont_fact_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of assoc_container_factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_assoc_cont_factory.hpp"
+
+int main()
+{
+ test_assoc_container_factory();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,71 @@
+/* Boost.Flyweight test of assoc_container_factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_assoc_cont_factory.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/assoc_container_factory.hpp>
+#include <boost/flyweight/flyweight.hpp>
+#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 "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct reverse_set_specifier
+{
+ template<typename Entry,typename Value>
+ struct apply
+ {
+ typedef std::set<Entry,std::greater<Value> > type;
+ };
+};
+
+struct assoc_container_factory_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ assoc_container_factory<reverse_set_specifier>
+ > type;
+ };
+};
+
+struct assoc_container_factory_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ assoc_container_factory_class<
+ lambda_set<
+ boost::mpl::_1,
+ lambda_greater<boost::mpl::_2>
+
+#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
+ ,std::allocator<boost::mpl::_1>
+#endif
+ >
+ >
+ > type;
+ };
+};
+
+void test_assoc_container_factory()
+{
+ BOOST_FLYWEIGHT_TEST_BASIC(assoc_container_factory_flyweight_specifier1)
+ BOOST_FLYWEIGHT_TEST_BASIC(assoc_container_factory_flyweight_specifier2)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_assoc_cont_factory.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of assoc_container_factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_assoc_container_factory();

Added: sandbox/flyweight/libs/flyweight/test/test_basic.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_basic.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,77 @@
+/* Boost.Flyweight basic test.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_basic.hpp"
+
+#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;
+
+struct basic_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T> type;
+ };
+};
+
+struct basic_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,tag<int>,
+ 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
+
+ >,
+ simple_locking,
+ refcounted
+ > type;
+ };
+};
+
+struct basic_flyweight_specifier3
+{
+ template<typename T>
+ struct apply
+ {
+ 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
+
+ >,
+ tag<int>
+ > type;
+ };
+};
+
+void test_basic()
+{
+ BOOST_FLYWEIGHT_TEST_BASIC(basic_flyweight_specifier1)
+ BOOST_FLYWEIGHT_TEST_BASIC(basic_flyweight_specifier2)
+ BOOST_FLYWEIGHT_TEST_BASIC(basic_flyweight_specifier3)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_basic.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_basic.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight basic test.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_basic();

Added: sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_basic_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight basic test.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_basic.hpp"
+
+int main()
+{
+ test_basic();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_basic_template.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,196 @@
+/* Boost.Flyweight basic test template.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_BASIC_TEMPLATE_HPP
+#define BOOST_FLYWEIGHT_TEST_BASIC_TEMPLATE_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/mpl/apply.hpp>
+#include <string>
+#include <sstream>
+
+#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+
+template<typename Flyweight,typename ForwardIterator>
+void test_basic_template(
+ ForwardIterator first,ForwardIterator last
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ typedef typename Flyweight::value_type value_type;
+
+ ForwardIterator it;
+
+ 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()));
+ BOOST_TEST(f1==c1);
+ BOOST_TEST(f2==c2);
+
+ f1=f1;
+ BOOST_TEST(f1==f1);
+
+ c1=f2;
+ BOOST_TEST(c1==f2);
+
+ c1=f1;
+ BOOST_TEST(c1==f1);
+
+ /* convertibility to underlying type */
+
+ value_type v1(f1);
+ BOOST_TEST(v1==f1.get());
+
+ /* identity of reference */
+
+ BOOST_TEST(&f1.get()==&c1.get());
+
+ /* modifiers */
+
+ f1.swap(f1);
+ BOOST_TEST(f1==c1);
+
+ f1.swap(f2);
+ BOOST_TEST(f1==c2);
+ BOOST_TEST(f2==c1);
+
+ boost::flyweights::swap(f1,f2);
+ BOOST_TEST(f1==c1);
+ BOOST_TEST(f2==c2);
+
+ /* specialized algorithms */
+
+ std::ostringstream oss1;
+ oss1<<f1;
+ std::ostringstream oss2;
+ oss2<<f1.get();
+ BOOST_TEST(oss1.str()==oss2.str());
+
+ std::istringstream iss1(oss1.str());
+ Flyweight f3;
+ iss1>>f3;
+ std::istringstream iss2(oss2.str());
+ value_type v3;
+ iss2>>v3;
+ BOOST_TEST(f3.get()==v3);
+ }
+}
+
+template<
+ typename Flyweight1,typename Flyweight2,
+ typename ForwardIterator1,typename ForwardIterator2
+>
+void test_basic_comparison_template(
+ ForwardIterator1 first1,ForwardIterator1 last1,
+ ForwardIterator2 first2
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight1)
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight2))
+{
+ typedef typename Flyweight1::value_type value_type1;
+ typedef typename Flyweight2::value_type value_type2;
+
+ for(;first1!=last1;++first1,++first2){
+ value_type1 v1=*first1;
+ value_type2 v2=*first2;
+ Flyweight1 f1(v1);
+ Flyweight2 f2(v2);
+
+ BOOST_TEST((f1==f2)==(f1.get()==v2));
+ BOOST_TEST((f1< f2)==(f1.get()< v2));
+ BOOST_TEST((f1!=f2)==(f1.get()!=v2));
+ BOOST_TEST((f1> f2)==(f1.get()> v2));
+ BOOST_TEST((f1>=f2)==(f1.get()>=v2));
+ BOOST_TEST((f1<=f2)==(f1.get()<=v2));
+
+#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
+ BOOST_TEST((f1==v2)==(f1.get()==v2));
+ BOOST_TEST((f1< v2)==(f1.get()< v2));
+ BOOST_TEST((f1!=v2)==(f1.get()!=v2));
+ BOOST_TEST((f1> v2)==(f1.get()> v2));
+ BOOST_TEST((f1>=v2)==(f1.get()>=v2));
+ BOOST_TEST((f1<=v2)==(f1.get()<=v2));
+
+ BOOST_TEST((v1==f2)==(f1.get()==v2));
+ BOOST_TEST((v1< f2)==(f1.get()< v2));
+ BOOST_TEST((v1!=f2)==(f1.get()!=v2));
+ BOOST_TEST((v1> f2)==(f1.get()> v2));
+ BOOST_TEST((v1>=f2)==(f1.get()>=v2));
+ BOOST_TEST((v1<=f2)==(f1.get()<=v2));
+#endif
+
+ }
+}
+
+template<typename FlyweightSpecifier>
+void test_basic_template(BOOST_EXPLICIT_TEMPLATE_TYPE(FlyweightSpecifier))
+{
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,int
+ >::type int_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,std::string
+ >::type string_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,char
+ >::type char_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));
+
+ const char* words[]={"hello","boost","flyweight","boost","bye","c++","c++"};
+ test_basic_template<string_flyweight>(&words[0],&words[0]+LENGTHOF(words));
+
+ 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]);
+}
+
+#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>(); \
+}
+
+#undef LENGTHOF
+
+#endif

Added: sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_custom_factory.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,111 @@
+/* Boost.Flyweight test of a custom factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_custom_factory.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#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 <list>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+/* Info on list-update containers:
+ * http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/lu_based_containers.html
+ */
+
+template<typename Entry,typename Value>
+class lu_factory_class:public factory_marker
+{
+ struct entry_type
+ {
+ entry_type(const Entry& x_):x(x_),count(0){}
+
+ Entry x;
+ std::size_t count;
+ };
+
+ typedef std::list<entry_type> container_type;
+
+public:
+ typedef typename container_type::iterator handle_type;
+
+ handle_type insert(const Entry& x)
+ {
+ handle_type h;
+ for(h=cont.begin();h!=cont.end();++h){
+ if(static_cast<const Value&>(h->x)==static_cast<const Value&>(x)){
+ if(++(h->count)==10){
+ h->count=0;
+ cont.splice(cont.begin(),cont,h); /* move to front */
+ }
+ return h;
+ }
+ }
+ cont.push_back(entry_type(x));
+ h=cont.end();
+ --h;
+ return h;
+ }
+
+ void erase(handle_type h)
+ {
+ cont.erase(h);
+ }
+
+ const Entry& entry(handle_type h){return h->x;}
+
+private:
+ container_type cont;
+
+public:
+ typedef lu_factory_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2,lu_factory_class,(Entry,Value))
+};
+
+struct lu_factory:factory_marker
+{
+ template<typename Entry,typename Value>
+ struct apply
+ {
+ typedef lu_factory_class<Entry,Value> type;
+ };
+};
+
+struct custom_factory_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,lu_factory> type;
+ };
+};
+
+struct custom_factory_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ lu_factory_class<boost::mpl::_1,boost::mpl::_2>
+ > type;
+ };
+};
+
+void test_custom_factory()
+{
+ BOOST_FLYWEIGHT_TEST_BASIC(custom_factory_flyweight_specifier1)
+ BOOST_FLYWEIGHT_TEST_BASIC(custom_factory_flyweight_specifier2)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_custom_factory.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of a custom factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_custom_factory();

Added: sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_custom_factory_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of a custom factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_custom_factory.hpp"
+
+int main()
+{
+ test_custom_factory();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_intermod_holder.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,34 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_intermod_holder.hpp"
+
+#include "intermod_holder_dll.hpp"
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct intermodule_holder_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,intermodule_holder> type;
+ };
+};
+
+void test_intermodule_holder()
+{
+ BOOST_FLYWEIGHT_TEST_BASIC(intermodule_holder_flyweight_specifier1)
+
+ intermodule_flyweight_string str=
+ create_intermodule_flyweight_string("boost");
+ BOOST_TEST(str==intermodule_flyweight_string("boost"));
+}

Added: sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_intermod_holder.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_intermodule_holder();

Added: sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_intermod_holder_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_intermod_holder.hpp"
+
+int main()
+{
+ test_intermodule_holder();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_multictor.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_multictor.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,106 @@
+/* Boost.Flyweight test of flyweight forwarding ctors.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_multictor.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+#include <boost/flyweight.hpp>
+#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;
+
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+#define NONCONST const
+#else
+#define NONCONST
+#endif
+
+struct multictor
+{
+ typedef multictor type;
+
+ multictor():
+ t(0,0,0.0,"",false){}
+ multictor(NONCONST int& x0):
+ t(x0,0,0.0,"",false){}
+ multictor(int x0,NONCONST char& x1):
+ t(x0,x1,0.0,"",false){}
+ multictor(int x0,char x1,NONCONST double& x2):
+ t(x0,x1,x2,"",false){}
+ multictor(int x0,char x1,double x2,NONCONST std::string& x3):
+ t(x0,x1,x2,x3,false){}
+ multictor(int x0,char x1,double x2,const std::string& x3,NONCONST bool& x4):
+ t(x0,x1,x2,x3,x4){}
+
+ friend bool operator==(const type& x,const type& y){return x.t==y.t;}
+ friend bool operator< (const type& x,const type& y){return x.t< y.t;}
+ friend bool operator!=(const type& x,const type& y){return x.t!=y.t;}
+ friend bool operator> (const type& x,const type& y){return x.t> y.t;}
+ friend bool operator>=(const type& x,const type& y){return x.t>=y.t;}
+ friend bool operator<=(const type& x,const type& y){return x.t<=y.t;}
+
+ boost::tuples::tuple<int,char,double,std::string,bool> t;
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+inline std::size_t hash_value(const multictor& x)
+{
+ std::size_t res=0;
+ boost::hash_combine(res,boost::tuples::get<0>(x.t));
+ boost::hash_combine(res,boost::tuples::get<1>(x.t));
+ boost::hash_combine(res,boost::tuples::get<2>(x.t));
+ boost::hash_combine(res,boost::tuples::get<3>(x.t));
+ boost::hash_combine(res,boost::tuples::get<4>(x.t));
+ return res;
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+void test_multictor()
+{
+ flyweight<multictor> f;
+ multictor m;
+ BOOST_TEST(f==m);
+
+ int x0=1;
+ flyweight<multictor> f0(x0);
+ multictor m0(x0);
+ BOOST_TEST(f0==m0);
+
+ char x1='a';
+ flyweight<multictor> f1(1,x1);
+ multictor m1(1,x1);
+ BOOST_TEST(f1==m1);
+
+ double x2=3.1416;
+ flyweight<multictor> f2(1,'a',x2);
+ multictor m2(1,'a',x2);
+ BOOST_TEST(f2==m2);
+
+ std::string x3("boost");
+ flyweight<multictor> f3(1,'a',3.1416,x3);
+ multictor m3(1,'a',3.1416,x3);
+ BOOST_TEST(f3==m3);
+
+ bool x4=true;
+ flyweight<multictor> f4(1,'a',3.1416,"boost",x4);
+ multictor m4(1,'a',3.1416,"boost",x4);
+ BOOST_TEST(f4==m4);
+}

Added: sandbox/flyweight/libs/flyweight/test/test_multictor.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_multictor.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of flyweight forwarding ctors.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_multictor();

Added: sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_multictor_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of flyweight forwarding ctors.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_multictor.hpp"
+
+int main()
+{
+ test_multictor();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_no_locking.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,35 @@
+/* Boost.Flyweight test of no_locking.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_no_locking.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/no_locking.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct no_locking_flyweight_specifier
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,no_locking> type;
+ };
+};
+
+void test_no_locking()
+{
+ BOOST_FLYWEIGHT_TEST_BASIC(no_locking_flyweight_specifier)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_no_locking.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of no_locking.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_no_locking();

Added: sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_no_locking_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of no_locking.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_no_locking.hpp"
+
+int main()
+{
+ test_no_locking();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_no_tracking.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,35 @@
+/* Boost.Flyweight test of no_tracking.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_no_tracking.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/no_tracking.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct no_tracking_flyweight_specifier
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,no_tracking> type;
+ };
+};
+
+void test_no_tracking()
+{
+ BOOST_FLYWEIGHT_TEST_BASIC(no_tracking_flyweight_specifier)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_no_tracking.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of no_tracking.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_no_tracking();

Added: sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_no_tracking_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of no_tracking.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_no_tracking.hpp"
+
+int main()
+{
+ test_no_tracking();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_serialization.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,31 @@
+/* Boost.Flyweight of serialization capabilities.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_serialization.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight.hpp>
+#include "test_serialization_template.hpp"
+
+using namespace boost::flyweights;
+
+struct serialization_flyweight_specifier
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T> type;
+ };
+};
+
+void test_serialization()
+{
+ BOOST_FLYWEIGHT_TEST_SERIALIZATION(serialization_flyweight_specifier)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_serialization.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight of serialization capabilities.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_serialization();

Added: sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight of serialization capabilities.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_serialization.hpp"
+
+int main()
+{
+ test_serialization();
+ return boost::report_errors();
+}

Added: sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_serialization_template.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,136 @@
+/* Boost.Flyweight test template for serialization capabilities.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_SERIALIZATION_TEMPLATE_HPP
+#define BOOST_FLYWEIGHT_TEST_SERIALIZATION_TEMPLATE_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/flyweight/serialize.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/serialization/vector.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+
+#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+
+struct tracked_string
+{
+ typedef tracked_string type;
+
+ tracked_string(){}
+ tracked_string(const char* str_):str(str_){}
+
+ const std::string& get()const{return str;}
+
+ friend bool operator==(const type& x,const type& y){return x.str==y.str;}
+ friend bool operator< (const type& x,const type& y){return x.str< y.str;}
+ friend bool operator!=(const type& x,const type& y){return x.str!=y.str;}
+ friend bool operator> (const type& x,const type& y){return x.str> y.str;}
+ friend bool operator>=(const type& x,const type& y){return x.str>=y.str;}
+ friend bool operator<=(const type& x,const type& y){return x.str<=y.str;}
+
+private:
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive& ar,const unsigned int){ar&str;}
+
+ std::string str;
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+inline std::size_t hash_value(const tracked_string& x)
+{
+ boost::hash<std::string> h;
+ return h(x.get());
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+template<typename Flyweight,typename ForwardIterator>
+void test_serialization_template(
+ ForwardIterator first,ForwardIterator last
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ std::vector<Flyweight> v1;
+ while(first!=last)v1.push_back(Flyweight(*first++));
+ std::ostringstream oss;
+ {
+ const std::vector<Flyweight>& crv1=v1;
+ boost::archive::text_oarchive oa(oss);
+ oa<<crv1;
+ }
+
+ std::vector<Flyweight> v2;
+ {
+ std::istringstream iss(oss.str());
+ boost::archive::text_iarchive ia(iss);
+ ia>>v2;
+ }
+
+ BOOST_TEST(v1==v2);
+}
+
+template<typename FlyweightSpecifier>
+void test_serialization_template(
+ BOOST_EXPLICIT_TEMPLATE_TYPE(FlyweightSpecifier))
+{
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,std::string
+ >::type string_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,tracked_string
+ >::type tracked_string_flyweight;
+
+ const char* words[]={"hello","boost","flyweight","boost","bye","c++","c++"};
+ test_serialization_template<string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words));
+ test_serialization_template<tracked_string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words));
+}
+
+#define BOOST_FLYWEIGHT_TEST_SERIALIZATION(FlyweightSpecifier) \
+{ \
+ /* Without these explicit instantiations, MSVC++ 6.5/7.0 does not \
+ * find some friend operators in certain contexts. \
+ */ \
+ \
+ typedef boost::mpl::apply1< \
+ FlyweightSpecifier,std::string \
+ >::type string_flyweight; \
+ \
+ typedef boost::mpl::apply1< \
+ FlyweightSpecifier,tracked_string \
+ >::type tracked_string_flyweight; \
+ \
+ string_flyweight f1;f1=f1; \
+ tracked_string_flyweight f2;f2=f2; \
+ \
+ test_serialization_template<FlyweightSpecifier>(); \
+}
+
+#undef LENGTHOF
+
+#endif

Added: sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_set_factory.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,80 @@
+/* Boost.Flyweight test of set_factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_set_factory.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#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;
+
+struct set_factory_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,set_factory<> > type;
+ };
+};
+
+struct set_factory_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ 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
+
+ >
+ > type;
+ };
+};
+
+struct set_factory_flyweight_specifier3
+{
+ template<typename T>
+ struct apply
+ {
+ 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
+
+ >,
+ static_holder_class<boost::mpl::_1>,
+ tag<char>
+ > type;
+ };
+};
+
+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)
+}

Added: sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_set_factory.hpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of set_factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+void test_set_factory();

Added: sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp
==============================================================================
--- (empty file)
+++ sandbox/flyweight/libs/flyweight/test/test_set_factory_main.cpp 2007-11-12 17:46:22 EST (Mon, 12 Nov 2007)
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of set_factory.
+ *
+ * Copyright 2006-2007 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include <boost/detail/lightweight_test.hpp>
+#include "test_set_factory.hpp"
+
+int main()
+{
+ test_set_factory();
+ return boost::report_errors();
+}


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