stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,79 @@
/* Copyright 2006-2014 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_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
@@ -0,0 +1,85 @@
/* Copyright 2006-2014 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)
#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/perfect_fwd.hpp>
#include <boost/flyweight/detail/value_tag.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 */
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)&&\
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)&&\
BOOST_WORKAROUND(__GNUC__,<=4)&&(__GNUC__<4||__GNUC_MINOR__<=4)
/* GCC 4.4.2 (and probably prior) bug: the default ctor generated by the
* variadic temmplate ctor below fails to value-initialize x.
*/
rep_type():x(){}
#endif
#define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \
:x(BOOST_FLYWEIGHT_FORWARD(args)){}
BOOST_FLYWEIGHT_PERFECT_FWD(
explicit rep_type,
BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY)
#undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY
rep_type(const rep_type& r):x(r.x){}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
rep_type(rep_type&& r):x(std::move(r.x)){}
#endif
operator const value_type&()const{return x;}
value_type x;
};
static void construct_value(const rep_type&){}
static void copy_value(const rep_type&){}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
static void move_value(const rep_type&){}
#endif
};
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#endif
@@ -0,0 +1,114 @@
/* Copyright 2006-2014 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_DYN_PERFECT_FWD_HPP
#define BOOST_FLYWEIGHT_DETAIL_DYN_PERFECT_FWD_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#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_from_to.hpp>
#include <boost/preprocessor/seq/seq.hpp>
#define BOOST_FLYWEIGHT_PERFECT_FWD_ARG(z,n,_) \
BOOST_PP_CAT(T,n)&& BOOST_PP_CAT(t,n)
#define BOOST_FLYWEIGHT_PERFECT_FWD_N_AUX(n,name,body) \
template<BOOST_PP_ENUM_PARAMS(n,typename T)> \
name(BOOST_PP_ENUM(n,BOOST_FLYWEIGHT_PERFECT_FWD_ARG,~)) \
body((FORWARD)(n))
#define BOOST_FLYWEIGHT_PERFECT_FWD_N(z,n,data) \
BOOST_FLYWEIGHT_PERFECT_FWD_N_AUX( \
n,BOOST_PP_SEQ_HEAD(data), \
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(data)))
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_PP_REPEAT_FROM_TO( \
1,BOOST_PP_ADD(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS,1), \
BOOST_FLYWEIGHT_PERFECT_FWD_N,(name)(body))
#define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \
name()body((ENUM)(0)) \
BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body)
#else
/* no rvalue refs -> [const] Tn& overloads */
#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/seq.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_MASK_AUX(r,name,body,mask) \
template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(mask),typename T)> \
name( \
BOOST_PP_ENUM( \
BOOST_PP_SEQ_SIZE(mask),BOOST_FLYWEIGHT_PERFECT_FWD_ARG,mask)) \
body((ENUM)(BOOST_PP_SEQ_SIZE(mask)))
#define BOOST_FLYWEIGHT_PERFECT_FWD_MASK(r,data) \
BOOST_FLYWEIGHT_PERFECT_FWD_MASK_AUX( \
r, \
BOOST_PP_SEQ_ELEM(0,BOOST_PP_SEQ_HEAD(data)), \
BOOST_PP_SEQ_ELEM(1,BOOST_PP_SEQ_HEAD(data)), \
BOOST_PP_SEQ_TAIL(data))
#define BOOST_FLYWEIGHT_01(z,n,_) ((0)(1))
/* Perfect forwarding overloads accepting 1 to n args */
#define BOOST_FLYWEIGHT_PERFECT_FWD_N(z,n,data) \
BOOST_PP_SEQ_FOR_EACH_PRODUCT( \
BOOST_FLYWEIGHT_PERFECT_FWD_MASK, \
((data)) \
BOOST_PP_REPEAT(n,BOOST_FLYWEIGHT_01,~))
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_PP_REPEAT_FROM_TO( \
1,BOOST_PP_ADD(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS,1), \
BOOST_FLYWEIGHT_PERFECT_FWD_N,(name)(body))
#define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \
name()body((ENUM)(0)) \
BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body)
#endif
#endif
@@ -0,0 +1,312 @@
/* Copyright 2006-2014 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)
#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/flyweight/detail/perfect_fwd.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 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 chk)
{
typedef typename core::lock_type lock_type;
core::init();
lock_type lock(core::mutex());
if(chk(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_INSERT_BODY(args) \
{ \
return insert_rep(rep_type(BOOST_FLYWEIGHT_FORWARD(args))); \
}
BOOST_FLYWEIGHT_PERFECT_FWD(
static handle_type insert,
BOOST_FLYWEIGHT_PERFECT_FWD_INSERT_BODY)
#undef BOOST_FLYWEIGHT_PERFECT_FWD_INSERT_BODY
static handle_type insert(const value_type& x){return insert_value(x);}
static handle_type insert(value_type& x){return insert_value(x);}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
static handle_type insert(const value_type&& x){return insert_value(x);}
static handle_type insert(value_type&& x){return insert_value(std::move(x));}
#endif
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());
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
base_handle_type h(factory().insert(std::move(e)));
#else
base_handle_type h(factory().insert(e));
#endif
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());
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
base_handle_type h(factory().insert(std::move(e)));
#else
base_handle_type h(factory().insert(e));
#endif
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);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
static handle_type insert_rep(rep_type&& x)
{
init();
entry_type e(std::move(x));
lock_type lock(mutex());
base_handle_type h(factory().insert(std::move(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(value_type&& x)
{
init();
entry_type e(rep_type(std::move(x)));
lock_type lock(mutex());
base_handle_type h(factory().insert(std::move(e)));
BOOST_TRY{
ValuePolicy::move_value(
static_cast<const rep_type&>(entry(h)));
}
BOOST_CATCH(...){
factory().erase(h);
BOOST_RETHROW;
}
BOOST_CATCH_END
return static_cast<handle_type>(h);
}
#endif
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
@@ -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)
#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
@@ -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)
#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
@@ -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)
#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
@@ -0,0 +1,90 @@
/* Copyright 2006-2014 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_PERFECT_FWD_HPP
#define BOOST_FLYWEIGHT_DETAIL_PERFECT_FWD_HPP
#if defined(_MSC_VER)
#pragma once
#endif
/* C++03-compatible implementation of perfect forwarding.
* Usage:
*
* # define NAME ...
* # define BODY(args) {...BOOST_FLYWEIGHT_FORWARD(args)...}
* BOOST_FLYWEIGHT_PERFECT_FWD(name,body)
*
* where NAME includes the return type and qualifiers (if any) and BODY(args)
* is expected to fo the forwarding through BOOST_FLYWEIGHT_FORWARD(args).
*
* In compilers capable of perfect forwarding, the real thing is provided
* (just one variadic args overload is generated). Otherwise the machinery
* generates n+1 overloads, if rvalue refs are supported, or else 2^(n+1)-1
* overloads accepting any combination of lvalue refs and const lvalue refs,
* up to BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS args.
*
* BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) is a variation omitting the
* overloads with zero args --when perfect forwarding is available, this second
* macro is exactly the same as the original.
*/
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/seq/seq.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
#define BOOST_FLYWEIGHT_FORWARD_FORWARD_AUX(z,n,_) \
std::forward<BOOST_PP_CAT(T,n)>(BOOST_PP_CAT(t,n))
#define BOOST_FLYWEIGHT_FORWARD_FORWARD(n) \
BOOST_PP_ENUM(n,BOOST_FLYWEIGHT_FORWARD_FORWARD_AUX,~)
#define BOOST_FLYWEIGHT_FORWARD_ENUM(n) BOOST_PP_ENUM_PARAMS(n,t)
#define BOOST_FLYWEIGHT_FORWARD_PASS(arg) arg
#define BOOST_FLYWEIGHT_FORWARD(args)\
BOOST_PP_CAT(BOOST_FLYWEIGHT_FORWARD_,BOOST_PP_SEQ_HEAD(args))( \
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(args)))
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)||\
defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if !defined(BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS)
#define BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS 5
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS<0
#error BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS must be >=0
#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
#else
/* real perfect forwarding */
#define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \
template<typename... Args>name(Args&&... args) \
body((PASS)(std::forward<Args>(args)...))
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS \
BOOST_FLYWEIGHT_PERFECT_FWD
#endif
#endif
@@ -0,0 +1,172 @@
/* Copyright 2006-2014 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_PP_PERFECT_FWD_HPP
#define BOOST_FLYWEIGHT_DETAIL_PP_PERFECT_FWD_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#define BOOST_FLYWEIGHT_PERFECT_FWD_0(name,body) \
name()body((FORWARD)(0))
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=1
#define BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body) \
template<typename T0> name(T0&& t0)body((FORWARD)(1))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=2
#define BOOST_FLYWEIGHT_PERFECT_FWD_2(name,body) \
template<typename T0,typename T1> name(T0&& t0,T1&& t1)body((FORWARD)(2))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=3
#define BOOST_FLYWEIGHT_PERFECT_FWD_3(name,body) \
template<typename T0,typename T1,typename T2> name(T0&& t0,T1&& t1,T2&& t2)body((FORWARD)(3))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=4
#define BOOST_FLYWEIGHT_PERFECT_FWD_4(name,body) \
template<typename T0,typename T1,typename T2,typename T3> name(T0&& t0,T1&& t1,T2&& t2,T3&& t3)body((FORWARD)(4))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=5
#define BOOST_FLYWEIGHT_PERFECT_FWD_5(name,body) \
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0&& t0,T1&& t1,T2&& t2,T3&& t3,T4&& t4)body((FORWARD)(5))
#endif
#else
/* no rvalue refs -> [const] Tn& overloads */
#define BOOST_FLYWEIGHT_PERFECT_FWD_0(name,body) \
name()body((ENUM)(0))
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=1
#define BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body) \
template<typename T0> name(T0& t0)body((ENUM)(1))\
template<typename T0> name(const T0& t0)body((ENUM)(1))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=2
#define BOOST_FLYWEIGHT_PERFECT_FWD_2(name,body) \
template<typename T0,typename T1> name(T0& t0,T1& t1)body((ENUM)(2))\
template<typename T0,typename T1> name(T0& t0,const T1& t1)body((ENUM)(2))\
template<typename T0,typename T1> name(const T0& t0,T1& t1)body((ENUM)(2))\
template<typename T0,typename T1> name(const T0& t0,const T1& t1)body((ENUM)(2))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=3
#define BOOST_FLYWEIGHT_PERFECT_FWD_3(name,body) \
template<typename T0,typename T1,typename T2> name(T0& t0,T1& t1,T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(T0& t0,T1& t1,const T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(T0& t0,const T1& t1,T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(T0& t0,const T1& t1,const T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(const T0& t0,T1& t1,T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(const T0& t0,T1& t1,const T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(const T0& t0,const T1& t1,T2& t2)body((ENUM)(3))\
template<typename T0,typename T1,typename T2> name(const T0& t0,const T1& t1,const T2& t2)body((ENUM)(3))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=4
#define BOOST_FLYWEIGHT_PERFECT_FWD_4(name,body) \
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,T1& t1,T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,T1& t1,T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,T1& t1,const T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,T1& t1,const T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,const T1& t1,T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,const T1& t1,T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,const T1& t1,const T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(T0& t0,const T1& t1,const T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,T1& t1,T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,T1& t1,T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,T1& t1,const T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,T1& t1,const T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,const T1& t1,T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,const T1& t1,T2& t2,const T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,const T1& t1,const T2& t2,T3& t3)body((ENUM)(4))\
template<typename T0,typename T1,typename T2,typename T3> name(const T0& t0,const T1& t1,const T2& t2,const T3& t3)body((ENUM)(4))
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS>=5
#define BOOST_FLYWEIGHT_PERFECT_FWD_5(name,body) \
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,const T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,const T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,const T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,T1& t1,const T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,const T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,const T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,const T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,const T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,const T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,const T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,T1& t1,const T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,const T2& t2,T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,const T2& t2,T3& t3,const T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,const T2& t2,const T3& t3,T4& t4)body((ENUM)(5))\
template<typename T0,typename T1,typename T2,typename T3,typename T4> name(const T0& t0,const T1& t1,const T2& t2,const T3& t3,const T4& t4)body((ENUM)(5))
#endif
#endif
#if BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==0
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body)
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==1
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body)
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==2
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_2(name,body)
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==3
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_2(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_3(name,body)
#elif BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==4
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_2(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_3(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_4(name,body)
#else /* BOOST_FLYWEIGHT_LIMIT_PERFECT_FWD_ARGS==5 */
#define BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_1(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_2(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_3(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_4(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_5(name,body)
#endif
#define BOOST_FLYWEIGHT_PERFECT_FWD(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_0(name,body) \
BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS(name,body)
#endif
@@ -0,0 +1,92 @@
/* Copyright 2006-2013 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)
#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/assert.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;
BOOST_VERIFY(pthread_mutexattr_init(&attr)==0);
BOOST_VERIFY(pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE)==0);
BOOST_VERIFY(pthread_mutex_init(&m_,&attr)==0);
BOOST_VERIFY(pthread_mutexattr_destroy(&attr)==0);
}
~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_)
{
BOOST_VERIFY(pthread_mutex_lock(&m_)==0);
}
~scoped_lock(){BOOST_VERIFY(pthread_mutex_unlock(&m_)==0);}
private:
pthread_mutex_t& m_;
};
private:
pthread_mutex_t m_;
};
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#endif
#endif
@@ -0,0 +1,99 @@
/* Copyright 2006-2014 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_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 <vector>
namespace boost{
namespace flyweights{
namespace detail{
/* The serialization helpers for flyweight<T> map numerical IDs to
* flyweight exemplars --an exemplar is the flyweight object
* associated to a given value that appears first on the serialization
* stream, so that subsequent equivalent flyweight objects will be made
* to refer to it during the serialization process.
*/
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 save_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();}
size_type find(const Flyweight& x)const
{
return multi_index::project<0>(t,multi_index::get<1>(t).find(&x.get()))
-t.begin();
}
void push_back(const Flyweight& x){t.push_back(x);}
private:
table t;
};
template<typename Flyweight>
class load_helper:private noncopyable
{
typedef std::vector<Flyweight> table;
public:
typedef typename table::size_type size_type;
size_type size()const{return t.size();}
Flyweight operator[](size_type n)const{return t[n];}
void push_back(const Flyweight& x){t.push_back(x);}
private:
table t;
};
} /* namespace flyweights::detail */
} /* namespace flyweights */
} /* namespace boost */
#endif
@@ -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)
#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