W
Werner
Hi All,
I want to try the following:
typedef CurveMetaDataIF<QPen,QBrush> BrushPenIF;
where the amount of elements in CurveMetaDataIF can be arbitrary.
BrushPenIF would be used as follows:
brushPenIF_->getData<QBrush>();
brushPenIF_->getData<QPen>();
....etc...
My first stab at the problem looked like this (used boost::mpl):
template <>
struct CurveMetaDataIF<>
{
virtual ~CurveMetaDataIF(){}
};
template <class Head, class... Tail>
struct CurveMetaDataIF<Head, Tail...> : CurveMetaDataIF<Tail...>
{
protected:
virtual Head getDataImpl( boost::identity<Head> ) const = 0;
public:
template <class DataT>
DataT getData()
{
return this->getDataImpl( boost::identity<DataT>() );
}
};
The problem with this approach is that getDataImpl of this
hides all bases.
I've come up with a nasty solution that finds the right base
(ugly), but was wondering whether anyone has some good
suggestion?
Help appreciated! Not homework...
Regards,
Werner
I want to try the following:
typedef CurveMetaDataIF<QPen,QBrush> BrushPenIF;
where the amount of elements in CurveMetaDataIF can be arbitrary.
BrushPenIF would be used as follows:
brushPenIF_->getData<QBrush>();
brushPenIF_->getData<QPen>();
....etc...
My first stab at the problem looked like this (used boost::mpl):
template <>
struct CurveMetaDataIF<>
{
virtual ~CurveMetaDataIF(){}
};
template <class Head, class... Tail>
struct CurveMetaDataIF<Head, Tail...> : CurveMetaDataIF<Tail...>
{
protected:
virtual Head getDataImpl( boost::identity<Head> ) const = 0;
public:
template <class DataT>
DataT getData()
{
return this->getDataImpl( boost::identity<DataT>() );
}
};
The problem with this approach is that getDataImpl of this
hides all bases.
I've come up with a nasty solution that finds the right base
(ugly), but was wondering whether anyone has some good
suggestion?
Help appreciated! Not homework...
Regards,
Werner