|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2002-10-04 18:13:34
"Aleksey Gurtovoy" <agurtovoy_at_[hidden]> wrote in message
news:4034600A4760D411B8720001031D84FB01096494_at_postoffice.office.meta...
> [...]
> And here's an equivalent definition that accepts both meta-function
classes
> and lambda expressions:
>
> template< typename F, typename T > struct le_apply
> {
> typedef typename mpl::lambda<F>::type f_;
> typedef typename mpl::apply1<f_,T>::type type;
> };
>
> template <
> typename T
> , typename OwnershipPolicy
> , typename ConversionPolicy
> , typename CheckingPolicy
> , typename StoragePolicy
> , typename sp_ = typename le_apply<StoragePolicy,T>::type
> >
> struct smart_ptr
> : sp_
> , le_apply<OwnershipPolicy, typename sp_::pointer_type>::type
> , le_apply<CheckingPolicy, typename sp_::pointer_type>::type
> {
> // ...
> };
> [...]
Bad news. On bcc 5.5.1, I'm trying this:
template
<
typename T,
class OwnershipPolicy = ref_counted<_>,
class ConversionPolicy = disallow_conversion<_>,
class CheckingPolicy = assert_check<_>,
class StoragePolicy = scalar_storage<_>
>
class smart_ptr;
template <typename F, typename T>
struct apply_lambda
{
typedef typename mpl::lambda<F>::type f_;
typedef typename mpl::apply<f_, T>::type type;
};
# define BOOST_STORAGE_POLICY \
apply_lambda<StoragePolicy, T>::type
# define BOOST_POINTER_TYPE(T) \
typename BOOST_STORAGE_POLICY::T
# define BOOST_CHECKING_POLICY \
apply_lambda<CheckingPolicy, BOOST_POINTER_TYPE(stored_type)>::type
# define BOOST_OWNERSHIP_POLICY \
apply_lambda<OwnershipPolicy, BOOST_POINTER_TYPE(pointer_type)>::type
# define BOOST_CONVERSION_POLICY \
apply_lambda<ConversionPolicy, BOOST_POINTER_TYPE(pointer_type)>::type
template <typename T, BOOST_SMART_POINTER_PARAMETERS>
class smart_ptr
: public optimally_inherit<
optimally_inherit<
BOOST_STORAGE_POLICY,
BOOST_OWNERSHIP_POLICY
>::type,
optimally_inherit<
BOOST_CHECKING_POLICY,
BOOST_CONVERSION_POLICY
>::type
>::type
{
//...
};
And I'm getting:
"Dependent type qualifier 'scalar_storage<_>' has no member named
'apply'"
Also, I had to specify 'using boost::mpl::_;', since it didn't recognize it
otherwise.
I notice that this is already done in MPL, though. Not sure what the deal
is.
BTW, I'm just #including <boost/mpl/lambda.hpp>. I'm not sure if I need
anything
else.
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk