Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* 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/detail/is_placeholder_expr.hpp>
#include <boost/flyweight/detail/nested_xxx_if_not_ph.hpp>
#include <boost/flyweight/factory_tag.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/mpl/if.hpp>
namespace boost{namespace flyweights{namespace detail{
BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(iterator);
BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(value_type);
}}} /* namespace boost::flyweights::detail */
/* Factory class using a given associative container.
*/
namespace boost{
namespace flyweights{
template<typename Container>
class assoc_container_factory_class:public factory_marker
{
public:
/* When assoc_container_factory_class<Container> is an MPL placeholder
* expression, referring to Container::iterator and Container::value_type
* force the MPL placeholder expression Container to be instantiated, which
* is wasteful and can fail in concept-checked STL implementations.
* We protect ourselves against this circumstance.
*/
typedef typename detail::nested_iterator_if_not_placeholder_expression<
Container
>::type handle_type;
typedef typename detail::nested_value_type_if_not_placeholder_expression<
Container
>::type entry_type;
handle_type insert(const entry_type& x)
{
return cont.insert(x).first;
}
void erase(handle_type h)
{
cont.erase(h);
}
static const entry_type& entry(handle_type h){return *h;}
private:
/* As above, avoid instantiating Container if it is an
* MPL placeholder expression.
*/
typedef typename mpl::if_<
detail::is_placeholder_expression<Container>,
int,
Container
>::type container_type;
container_type 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 Key>
struct apply
{
typedef assoc_container_factory_class<
typename mpl::apply2<ContainerSpecifier,Entry,Key>::type
> type;
};
};
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,35 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,58 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
#define BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/flyweight/detail/value_tag.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
/* Default value policy: the key is the same as the value.
*/
namespace boost{
namespace flyweights{
namespace detail{
template<typename Value>
struct default_value_policy:value_marker
{
typedef Value key_type;
typedef Value value_type;
struct rep_type
{
/* template ctors */
#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit rep_type
#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
:x(BOOST_PP_ENUM_PARAMS(n,t)){}
#include <boost/flyweight/detail/perfect_fwd.hpp>
operator const value_type&()const{return x;}
value_type x;
};
static void construct_value(const rep_type&){}
static void copy_value(const rep_type&){}
};
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,75 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
/* no include guards */
#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_PERFECT_FWD_ARG(z,n,mask) \
BOOST_FLYWEIGHT_CONST(BOOST_PP_SEQ_ELEM(n,mask)) \
BOOST_PP_CAT(T,n)& BOOST_PP_CAT(t,n)
/* overload 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_PERFECT_FWD(r,mask) \
template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(mask),typename T)> \
BOOST_FLYWEIGHT_PERFECT_FWD_NAME( \
BOOST_PP_ENUM( \
BOOST_PP_SEQ_SIZE(mask),BOOST_FLYWEIGHT_PERFECT_FWD_ARG,mask)) \
BOOST_FLYWEIGHT_PERFECT_FWD_BODY(BOOST_PP_SEQ_SIZE(mask))
#define BOOST_FLYWEIGHT_01(z,n,_) ((0)(1))
/* Perfect forwarding overloads accepting 1 to n args */
#define BOOST_FLYWEIGHT_PERFECT_FWDS_N(z,n,_) \
BOOST_PP_SEQ_FOR_EACH_PRODUCT( \
BOOST_FLYWEIGHT_PERFECT_FWD, \
BOOST_PP_REPEAT(n,BOOST_FLYWEIGHT_01,~))
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS \
BOOST_PP_REPEAT_FROM_TO( \
1,BOOST_PP_ADD(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS,1), \
BOOST_FLYWEIGHT_PERFECT_FWDS_N,~)
/* generate the overloads */
BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS
/* clean up */
#undef BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS
#undef BOOST_FLYWEIGHT_01
#undef BOOST_FLYWEIGHT_PERFECT_FWD
#undef BOOST_FLYWEIGHT_PERFECT_FWD_ARG
#undef BOOST_FLYWEIGHT_CONST1
#undef BOOST_FLYWEIGHT_CONST0
#undef BOOST_FLYWEIGHT_CONST
/* user supplied argument macros */
#undef BOOST_FLYWEIGHT_PERFECT_FWD_BODY
#undef BOOST_FLYWEIGHT_PERFECT_FWD_NAME

View File

@@ -0,0 +1,252 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* 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/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(push)
#pragma warning(disable:4101) /* unreferenced local vars */
#endif
/* flyweight_core provides the inner implementation of flyweight<> by
* weaving together a value policy, a flyweight factory, a holder for the
* factory,a tracking policy and a locking policy.
*/
namespace boost{
namespace flyweights{
namespace detail{
template<
typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
class flyweight_core;
template<
typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
struct flyweight_core_tracking_helper
{
private:
typedef flyweight_core<
ValuePolicy,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::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 ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
class flyweight_core
{
public:
typedef typename ValuePolicy::key_type key_type;
typedef typename ValuePolicy::value_type value_type;
typedef typename ValuePolicy::rep_type rep_type;
typedef typename mpl::apply2<
typename TrackingPolicy::entry_type,
rep_type,
key_type
>::type entry_type;
typedef typename mpl::apply2<
FactorySpecifier,
entry_type,
key_type
>::type factory_type;
typedef typename factory_type::handle_type base_handle_type;
typedef typename mpl::apply2<
typename TrackingPolicy::handle_type,
base_handle_type,
flyweight_core_tracking_helper<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,
HolderSpecifier
>
>::type handle_type;
typedef typename LockingPolicy::mutex_type mutex_type;
typedef typename LockingPolicy::lock_type lock_type;
static bool init()
{
if(static_initializer)return true;
else{
holder_arg& a=holder_type::get();
static_factory_ptr=&a.factory;
static_mutex_ptr=&a.mutex;
static_initializer=(static_factory_ptr!=0);
return static_initializer;
}
}
/* insert overloads*/
#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME static handle_type insert
#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
{ \
return insert_rep(rep_type(BOOST_PP_ENUM_PARAMS(n,t))); \
}
#include <boost/flyweight/detail/perfect_fwd.hpp>
static handle_type insert(const value_type& x){return insert_value(x);}
static handle_type insert(value_type& x){return insert_value(x);}
static const entry_type& entry(const base_handle_type& h)
{
return factory().entry(h);
}
static const value_type& value(const handle_type& h)
{
return static_cast<const rep_type&>(entry(h));
}
static const key_type& key(const handle_type& h)
{
return static_cast<const rep_type&>(entry(h));
}
static factory_type& factory()
{
return *static_factory_ptr;
}
static mutex_type& mutex()
{
return *static_mutex_ptr;
}
private:
struct holder_arg
{
factory_type factory;
mutex_type mutex;
};
typedef typename mpl::apply1<
HolderSpecifier,
holder_arg
>::type holder_type;
static handle_type insert_rep(const rep_type& x)
{
init();
entry_type e(x);
lock_type lock(mutex());
base_handle_type h(factory().insert(e));
BOOST_TRY{
ValuePolicy::construct_value(
static_cast<const rep_type&>(entry(h)));
}
BOOST_CATCH(...){
factory().erase(h);
BOOST_RETHROW;
}
BOOST_CATCH_END
return static_cast<handle_type>(h);
}
static handle_type insert_value(const value_type& x)
{
init();
entry_type e((rep_type(x)));
lock_type lock(mutex());
base_handle_type h(factory().insert(e));
BOOST_TRY{
ValuePolicy::copy_value(
static_cast<const rep_type&>(entry(h)));
}
BOOST_CATCH(...){
factory().erase(h);
BOOST_RETHROW;
}
BOOST_CATCH_END
return static_cast<handle_type>(h);
}
static bool static_initializer;
static factory_type* static_factory_ptr;
static mutex_type* static_mutex_ptr;
};
template<
typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
bool
flyweight_core<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::static_initializer=
flyweight_core<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::init();
template<
typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
typename flyweight_core<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::factory_type*
flyweight_core<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::static_factory_ptr=0;
template<
typename ValuePolicy,typename Tag,typename TrackingPolicy,
typename FactorySpecifier,typename LockingPolicy,typename HolderSpecifier
>
typename flyweight_core<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::mutex_type*
flyweight_core<
ValuePolicy,Tag,TrackingPolicy,
FactorySpecifier,LockingPolicy,HolderSpecifier>::static_mutex_ptr=0;
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(pop)
#endif
#endif

View File

@@ -0,0 +1,65 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_DETAIL_IS_PLACEHOLDER_EXPR_HPP
#define BOOST_FLYWEIGHT_DETAIL_IS_PLACEHOLDER_EXPR_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/mpl/not.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
namespace boost{
namespace flyweights{
namespace detail{
/* is_placeholder_expression<T> indicates whether T is an
* MPL placeholder expression.
*/
template<typename T>
struct is_placeholder_expression_helper
{
template<
BOOST_PP_ENUM_PARAMS(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT)
>
struct apply{
typedef int type;
};
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_placeholder_expression_helper,(T))
};
template<typename T>
struct is_placeholder_expression:
mpl::not_<is_same<
typename mpl::apply<
is_placeholder_expression_helper<T>,
BOOST_PP_ENUM_PARAMS(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY,int BOOST_PP_INTERCEPT)
>::type,
int
> >
{};
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,39 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_DETAIL_NESTED_XXX_IF_NOT_PH_HPP
#define BOOST_FLYWEIGHT_DETAIL_NESTED_XXX_IF_NOT_PH_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/flyweight/detail/is_placeholder_expr.hpp>
#include <boost/mpl/if.hpp>
/* nested_##name##_if_not_placeholder_expression<T>::type is T::name unless
* T is an MPL placeholder expression, in which case it defaults to int.
*/
#define BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(name) \
struct nested_##name##_if_not_placeholder_expression_helper \
{ \
typedef int name; \
}; \
\
template<typename T> \
struct nested_##name##_if_not_placeholder_expression \
{ \
typedef typename boost::mpl::if_< \
boost::flyweights::detail::is_placeholder_expression<T>, \
nested_##name##_if_not_placeholder_expression_helper, \
T \
>::type::name type; \
};
#endif

View File

@@ -0,0 +1,58 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_DETAIL_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

View File

@@ -0,0 +1,28 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
/* Brute force implementation of perfect forwarding overloads.
* Usage: include after having defined the argument macros:
* BOOST_FLYWEIGHT_PERFECT_FWD_NAME
* BOOST_FLYWEIGHT_PERFECT_FWD_BODY
*/
/* This user_definable macro limits the maximum number of arguments to
* be perfect forwarded. Beware combinatorial explosion: manual perfect
* forwarding for n arguments produces 2^n distinct overloads.
*/
#if !defined(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS)
#define BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS 5
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS<=5
#include <boost/flyweight/detail/pp_perfect_fwd.hpp>
#else
#include <boost/flyweight/detail/dyn_perfect_fwd.hpp>
#endif

View File

@@ -0,0 +1,153 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
/* no include guards */
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=1
#define BOOST_FLYWEIGHT_PERFECT_FWDS_1 \
template<typename T0> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(1)\
template<typename T0> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(1)
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=2
#define BOOST_FLYWEIGHT_PERFECT_FWDS_2 \
template<typename T0,typename T1> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(2)\
template<typename T0,typename T1> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(2)\
template<typename T0,typename T1> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(2)\
template<typename T0,typename T1> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(2)
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=3
#define BOOST_FLYWEIGHT_PERFECT_FWDS_3 \
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)\
template<typename T0,typename T1,typename T2> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(3)
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=4
#define BOOST_FLYWEIGHT_PERFECT_FWDS_4 \
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2,T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)\
template<typename T0,typename T1,typename T2,typename T3> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2,const T3& t3)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(4)
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=5
#define BOOST_FLYWEIGHT_PERFECT_FWDS_5 \
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,T1& t1,const T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,T1& t1,const T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2,T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2,T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2,const T3& t3,T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)\
template<typename T0,typename T1,typename T2,typename T3,typename T4> BOOST_FLYWEIGHT_PERFECT_FWD_NAME(const T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4)BOOST_FLYWEIGHT_PERFECT_FWD_BODY(5)
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==0
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==1
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS \
BOOST_FLYWEIGHT_PERFECT_FWDS_1
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==2
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS \
BOOST_FLYWEIGHT_PERFECT_FWDS_1 \
BOOST_FLYWEIGHT_PERFECT_FWDS_2
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==3
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS \
BOOST_FLYWEIGHT_PERFECT_FWDS_1 \
BOOST_FLYWEIGHT_PERFECT_FWDS_2 \
BOOST_FLYWEIGHT_PERFECT_FWDS_3
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==4
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS \
BOOST_FLYWEIGHT_PERFECT_FWDS_1 \
BOOST_FLYWEIGHT_PERFECT_FWDS_2 \
BOOST_FLYWEIGHT_PERFECT_FWDS_3 \
BOOST_FLYWEIGHT_PERFECT_FWDS_4
#else /* BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==5 */
#define BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS \
BOOST_FLYWEIGHT_PERFECT_FWDS_1 \
BOOST_FLYWEIGHT_PERFECT_FWDS_2 \
BOOST_FLYWEIGHT_PERFECT_FWDS_3 \
BOOST_FLYWEIGHT_PERFECT_FWDS_4 \
BOOST_FLYWEIGHT_PERFECT_FWDS_5
#endif
/* generate the overloads */
BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS
/* clean up */
#undef BOOST_FLYWEIGHT_PERFECT_FWD_OVERLOADS
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=1
#undef BOOST_FLYWEIGHT_PERFECT_FWDS_1
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=2
#undef BOOST_FLYWEIGHT_PERFECT_FWDS_2
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=3
#undef BOOST_FLYWEIGHT_PERFECT_FWDS_3
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=4
#undef BOOST_FLYWEIGHT_PERFECT_FWDS_4
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=5
#undef BOOST_FLYWEIGHT_PERFECT_FWDS_5
#endif
/* user supplied argument macros */
#undef BOOST_FLYWEIGHT_PERFECT_FWD_NAME
#undef BOOST_FLYWEIGHT_PERFECT_FWD_BODY

View File

@@ -0,0 +1,91 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_DETAIL_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

View File

@@ -0,0 +1,50 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_DETAIL_VALUE_TAG_HPP
#define BOOST_FLYWEIGHT_DETAIL_VALUE_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{
namespace detail{
/* Three ways to indicate that a given class T is a value policy:
* 1. Make it derived from value_marker.
* 2. Specialize is_value to evaluate to boost::mpl::true_.
* 3. Pass it as value<T> when defining a flyweight type.
*
* For the time being the interface of value policies is not public.
*/
struct value_marker{};
template<typename T>
struct is_value:is_base_and_derived<value_marker,T>
{};
template<typename T=parameter::void_>
struct value:parameter::template_keyword<value<>,T>
{};
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,44 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,407 @@
/* Flyweight class.
*
* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* 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/default_value_policy.hpp>
#include <boost/flyweight/detail/flyweight_core.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/assert.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/or.hpp>
#include <boost/parameter/binding.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/swap.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(push)
#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;
/* Boost.Parameter structures for use in flyweight.
* NB: these types are derived from instead of typedef'd to force their
* instantiation, which solves http://bugs.sun.com/view_bug.do?bug_id=6782987
* as found out by Simon Atanasyan.
*/
struct flyweight_signature:
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::_>
>
>
{};
struct flyweight_unmatched_signature:
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::_>
>
>
>
>
{};
} /* namespace flyweights::detail */
template<
typename T,
typename Arg1,typename Arg2,typename Arg3,typename Arg4,typename Arg5
>
class flyweight
{
private:
typedef typename mpl::if_<
detail::is_value<T>,
T,
detail::default_value_policy<T>
>::type value_policy;
typedef typename detail::
flyweight_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 typename detail::
flyweight_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;
/* You have passed a type in the specification of a flyweight type that
* could not be interpreted as a valid argument.
*/
BOOST_MPL_ASSERT_MSG(
(is_same<unmatched_arg_detected,detail::unmatched_arg>::value),
INVALID_ARGUMENT_TO_FLYWEIGHT,
(flyweight));
typedef detail::flyweight_core<
value_policy,tag_type,tracking_policy,
factory_specifier,locking_policy,
holder_specifier
> core;
typedef typename core::handle_type handle_type;
public:
typedef typename value_policy::key_type key_type;
typedef typename value_policy::value_type value_type;
/* static data initialization */
static bool init(){return core::init();}
class initializer
{
public:
initializer():b(init()){}
private:
bool b;
};
/* construct/copy/destroy */
flyweight():h(core::insert(key_type())){}
flyweight(const flyweight& x):h(x.h){}
flyweight(flyweight& x):h(x.h){}
/* template ctors */
#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit flyweight
#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
:h(core::insert(BOOST_PP_ENUM_PARAMS(n,t))){}
#include <boost/flyweight/detail/perfect_fwd.hpp>
flyweight& operator=(const flyweight& x){h=x.h;return *this;}
flyweight& operator=(const value_type& x){return operator=(flyweight(x));}
/* convertibility to underlying type */
const key_type& get_key()const{return core::key(h);}
const value_type& get()const{return core::value(h);}
operator const value_type&()const{return get();}
/* exact type equality */
friend bool operator==(const flyweight& x,const flyweight& y)
{
return &x.get()==&y.get();
}
/* modifiers */
void swap(flyweight& x){boost::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)
{
typedef typename flyweight<
T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)
>::value_type value_type;
/* value_type need not be default ctble but must be copy ctble */
value_type t(x.get());
in>>t;
x=t;
return in;
}
} /* namespace flyweights */
} /* namespace boost */
#undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS
#undef BOOST_FLYWEIGHT_TEMPL_ARGS
#undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
#pragma warning(pop)
#endif
#endif

View File

@@ -0,0 +1,166 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,114 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* 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 Key,
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<Key>,
Hash
>::type,
typename boost::mpl::if_<
mpl::is_na<Pred>,
std::equal_to<Key>,
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));
}
static 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,Key,Hash,Pred,Allocator))
};
/* hashed_factory_class specifier */
template<
typename Hash,typename Pred,typename Allocator
BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
>
struct hashed_factory:factory_marker
{
template<typename Entry,typename Key>
struct apply:
mpl::apply2<
hashed_factory_class<
boost::mpl::_1,boost::mpl::_2,Hash,Pred,Allocator
>,
Entry,Key
>
{};
};
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,40 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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 Key,
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

View File

@@ -0,0 +1,44 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,54 @@
/* Copyright 2006-2011 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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/interprocess/detail/intermodule_singleton.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
/* 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:
interprocess::ipcdetail::intermodule_singleton<C,true>,
holder_marker
{
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

View File

@@ -0,0 +1,29 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,238 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_KEY_VALUE_HPP
#define BOOST_FLYWEIGHT_KEY_VALUE_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
#include <boost/flyweight/detail/value_tag.hpp>
#include <boost/flyweight/key_value_fwd.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/type_traits/aligned_storage.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/is_same.hpp>
#include <new>
/* key-value policy: flywewight lookup is based on Key, which also serves
* to construct Value only when needed (new factory entry). key_value is
* used to avoid the construction of temporary values when such construction
* is expensive.
* Optionally, KeyFromValue extracts the key from a value, which
* is needed in expressions like this:
*
* typedef flyweight<key_value<Key,Value> > fw_t;
* fw_t fw;
* Value v;
* fw=v; // no key explicitly given
*
* If no KeyFromValue is provided, this latter expression fails to compile.
*/
namespace boost{
namespace flyweights{
namespace detail{
template<typename Key,typename Value,typename KeyFromValue>
struct optimized_key_value:value_marker
{
typedef Key key_type;
typedef Value value_type;
class rep_type
{
public:
/* template ctors */
#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit rep_type
#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
:value_ptr(0) \
{ \
new(spc_ptr())key_type(BOOST_PP_ENUM_PARAMS(n,t)); \
}
#include <boost/flyweight/detail/perfect_fwd.hpp>
rep_type(const value_type& x):value_ptr(&x){}
rep_type(const rep_type& x):value_ptr(x.value_ptr)
{
if(!x.value_ptr)new(key_ptr())key_type(*x.key_ptr());
}
~rep_type()
{
if(!value_ptr) key_ptr()->~key_type();
else if(value_cted())value_ptr->~value_type();
}
operator const key_type&()const
{
if(value_ptr)return key_from_value(*value_ptr);
else return *key_ptr();
}
operator const value_type&()const
{
/* This is always called after construct_value() or copy_value(),
* so we access spc directly rather than through value_ptr to
* save us an indirection.
*/
return *static_cast<value_type*>(spc_ptr());
}
private:
friend struct optimized_key_value;
void* spc_ptr()const{return static_cast<void*>(&spc);}
bool value_cted()const{return value_ptr==spc_ptr();}
key_type* key_ptr()const
{
return static_cast<key_type*>(static_cast<void*>(&spc));
}
static const key_type& key_from_value(const value_type& x)
{
KeyFromValue k;
return k(x);
}
void construct_value()const
{
if(!value_cted()){
/* value_ptr must be ==0, oherwise copy_value would have been called */
key_type k(*key_ptr());
key_ptr()->~key_type();
value_ptr= /* guarantees key won't be re-dted at ~rep_type if the */
static_cast<value_type*>(spc_ptr())+1; /* next statement throws */
value_ptr=new(spc_ptr())value_type(k);
}
}
void copy_value()const
{
if(!value_cted())value_ptr=new(spc_ptr())value_type(*value_ptr);
}
mutable typename boost::aligned_storage<
(sizeof(key_type)>sizeof(value_type))?
sizeof(key_type):sizeof(value_type),
(boost::alignment_of<key_type>::value >
boost::alignment_of<value_type>::value)?
boost::alignment_of<key_type>::value:
boost::alignment_of<value_type>::value
>::type spc;
mutable const value_type* value_ptr;
};
static void construct_value(const rep_type& r)
{
r.construct_value();
}
static void copy_value(const rep_type& r)
{
r.copy_value();
}
};
template<typename Key,typename Value>
struct regular_key_value:value_marker
{
typedef Key key_type;
typedef Value value_type;
class rep_type
{
public:
/* template ctors */
#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit rep_type
#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
:key(BOOST_PP_ENUM_PARAMS(n,t)),value_ptr(0){}
#include <boost/flyweight/detail/perfect_fwd.hpp>
rep_type(const value_type& x):key(no_key_from_value_failure()){}
rep_type(const rep_type& x):key(x.key),value_ptr(0){}
~rep_type()
{
if(value_ptr)value_ptr->~value_type();
}
operator const key_type&()const{return key;}
operator const value_type&()const
{
/* This is always called after construct_value(),so we access spc
* directly rather than through value_ptr to save us an indirection.
*/
return *static_cast<value_type*>(spc_ptr());
}
private:
friend struct regular_key_value;
void* spc_ptr()const{return static_cast<void*>(&spc);}
struct no_key_from_value_failure
{
BOOST_MPL_ASSERT_MSG(
false,
NO_KEY_FROM_VALUE_CONVERSION_PROVIDED,
(key_type,value_type));
operator const key_type&()const;
};
void construct_value()const
{
if(!value_ptr)value_ptr=new(spc_ptr())value_type(key);
}
key_type key;
mutable typename boost::aligned_storage<
sizeof(value_type),
boost::alignment_of<value_type>::value
>::type spc;
mutable const value_type* value_ptr;
};
static void construct_value(const rep_type& r)
{
r.construct_value();
}
static void copy_value(const rep_type&){}
};
} /* namespace flyweights::detail */
template<typename Key,typename Value,typename KeyFromValue>
struct key_value:
mpl::if_<
is_same<KeyFromValue,no_key_from_value>,
detail::regular_key_value<Key,Value>,
detail::optimized_key_value<Key,Value,KeyFromValue>
>::type
{};
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,29 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_KEY_VALUE_FWD_HPP
#define BOOST_FLYWEIGHT_KEY_VALUE_FWD_HPP
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
#pragma once
#endif
namespace boost{
namespace flyweights{
struct no_key_from_value;
template<typename Key,typename Value,typename KeyFromValue=no_key_from_value>
struct key_value;
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,44 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,36 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,26 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,46 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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,typename Key>
struct apply{typedef Value type;};
};
struct handle_type
{
template<typename Handle,typename TrackingHelper>
struct apply{typedef Handle type;};
};
};
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,26 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,160 @@
/* Copyright 2006-2010 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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>
#include <boost/utility/swap.hpp>
/* Refcounting tracking policy.
* The implementation deserves some explanation; values are equipped with two
* reference counts:
* - a regular count of active references
* - a deleter count
* It looks like a value can be erased when the number of references reaches
* zero, but this condition alone can lead to data races:
* - Thread A detaches the last reference to x and is preempted.
* - Thread B looks for x, finds it and attaches a reference to it.
* - Thread A resumes and proceeds with erasing x, leaving a dangling
* reference in thread B.
* Here is where the deleter count comes into play. This count is
* incremented when the reference count changes from 0 to 1, and decremented
* when a thread is about to check a value for erasure; it can be seen that a
* value is effectively erasable only when the deleter count goes down to 0
* (unless there are dangling references due to abnormal program termination,
* for instance if std::exit is called).
*/
namespace boost{
namespace flyweights{
namespace detail{
template<typename Value,typename Key>
class refcounted_value
{
public:
explicit refcounted_value(const Value& x_):
x(x_),ref(0),del_ref(0)
{}
refcounted_value(const refcounted_value& r):
x(r.x),ref(0),del_ref(0)
{}
refcounted_value& operator=(const refcounted_value& r)
{
x=r.x;
return *this;
}
operator const Value&()const{return x;}
operator const Key&()const{return x;}
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
private:
template<typename,typename> friend class refcounted_handle;
#endif
long count()const{return ref;}
long add_ref()const{return ++ref;}
bool release()const{return (--ref==0);}
void add_deleter()const{++del_ref;}
bool release_deleter()const{return (--del_ref==0);}
private:
Value x;
mutable boost::detail::atomic_count ref;
mutable long del_ref;
};
template<typename Handle,typename TrackingHelper>
class refcounted_handle
{
public:
explicit refcounted_handle(const Handle& h_):h(h_)
{
if(TrackingHelper::entry(*this).add_ref()==1){
TrackingHelper::entry(*this).add_deleter();
}
}
refcounted_handle(const refcounted_handle& x):h(x.h)
{
TrackingHelper::entry(*this).add_ref();
}
refcounted_handle& operator=(refcounted_handle x)
{
swap(*this,x);
return *this;
}
~refcounted_handle()
{
if(TrackingHelper::entry(*this).release()){
TrackingHelper::erase(*this,check_erase);
}
}
operator const Handle&()const{return h;}
friend void swap(refcounted_handle& x, refcounted_handle& y)
{
boost::swap(x.h,y.h);
}
private:
static bool check_erase(const refcounted_handle& x)
{
return TrackingHelper::entry(x).release_deleter();
}
Handle h;
};
} /* namespace flyweights::detail */
struct refcounted:tracking_marker
{
struct entry_type
{
template<typename Value,typename Key>
struct apply
{
typedef detail::refcounted_value<Value,Key> type;
};
};
struct handle_type
{
template<typename Handle,typename TrackingHelper>
struct apply
{
typedef detail::refcounted_handle<Handle,TrackingHelper> type;
};
};
};
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,26 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,82 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* 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 Key,
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<Key>,
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,Key,Compare,Allocator))
};
/* set_factory_class specifier */
template<
typename Compare,typename Allocator
BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
>
struct set_factory:factory_marker
{
template<typename Entry,typename Key>
struct apply:
mpl::apply2<
set_factory_class<
boost::mpl::_1,boost::mpl::_2,Compare,Allocator
>,
Entry,Key
>
{};
};
} /* namespace flyweights */
} /* namespace boost */
#endif

View File

@@ -0,0 +1,40 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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 Key,
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

View File

@@ -0,0 +1,37 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,26 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,56 @@
/* Copyright 2006-2009 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* 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

View File

@@ -0,0 +1,29 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

46
test/external/boost/flyweight/tag.hpp vendored Normal file
View File

@@ -0,0 +1,46 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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

View File

@@ -0,0 +1,44 @@
/* Copyright 2006-2008 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/flyweight for library home page.
*/
#ifndef BOOST_FLYWEIGHT_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